简体   繁体   中英

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

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?

如果你想要一种方式数据绑定只是使用

[ngModel]="categories.name"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM