I'm having trouble setting the value of a template driven form input. The value is coming from an editMovie object. I want the form to be filled with the editMovie values when shown and the user can then edit a part of the editMovie object or leave it the same. The form value is being set correctly for inputs that don't have [(ngModel)] attachted to them but the one's that do won't set a default value. Here is an example:
<div class="form-group">
<label for="imdb">Edit IMDb ID</label>
<input #editImdb type="text" class="form-control" name="imdb" [(ngModel)]="editReviewForm.imdb" [value]="editMovie.imdb" required="" />
<div class="mt-1" style="color:red">
*required
</div>
</div>
<div class="form-group">
<label for="trailer">Edit Youtube Trailer</label>
<input #editTrailer type="text" class="form-control" name="trailer" value="{{ editMovie.trailer }}" />
</div>
The first one doesn't work while the second one does. Following SO questions here I tried putting the value property in a two way data binding like this: [(value)] but that didn't work. Following this SO question I tried [ngValue] but this threw a parse error in the browser Can't bind to 'ngValue' since it isn't a known property of 'input'
Does anybody know how to bind the value for a template driven form input?
[(ngModel)]and NOT thevalue.ngModelis for two way binding, which sets the default and keeps the associated component property in sync. Binding also to thevalueproperty is most likely confusing things.[value]. How would I use[(ngModel)]?