Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 6: Input with initial value without two way data binding

Tags:

angular

I want to give my input a initial value. It should be without two way databinding so not [(ngModel)]="categories.name". I have tried this:

<form (ngSubmit)="onEditCategoie(f)" #f="ngForm">
    <div class="form-group">
      <label for="name">Name</label>
      <input id="name" type="text" class="form-control" placeholder="Kategorie Name" name="name" [value]="categorie.name" ngModel required>
    </div>
<form>

But that doesn't work. Any idea?

like image 601
Jonas Avatar asked Nov 25 '25 11:11

Jonas


1 Answers

If you want one way data binding just use

[ngModel]="categories.name"
like image 81
Sajeetharan Avatar answered Nov 26 '25 23:11

Sajeetharan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!