Reputation: 287
I am working on submitting a form using ngsubmit
I get all the input fields except for ngSelect
. This always returns undefined
I tried with [value]
and [ngValue]
both returns undefined
<div class="form-group">
<label for="category">Category</label>
<select ngModel name="category" id="category" class="form-control">
<option [ngValue]=""></option>
<option *ngFor="let c of categories$ | async" [ngValue]="c.$key">
{{c.name}}
</option>
</select>
</div>
and for form submission
<form #f="ngForm" (ngSubmit)="save(f.value)">
Could anyone please help me understand what is that i am doing wrong
Upvotes: 0
Views: 1197
Reputation: 22203
Try this:
Replace ngModel
with [(ngModel)]="category"
<div class="form-group">
<label for="category">Category</label>
<select [(ngModel)]="category" name="category" id="category" class="form-control">
<option [ngValue]=""></option>
<option *ngFor="let c of categories$ | async" [ngValue]="c.$key">
{{c.name}}
</option>
</select>
</div>
Upvotes: 2