@Component({
selector: 'filter',
template: "<select [(ngModel)]="filterState" (change)="selected()">
<option value="">All</option>
<option *ngFor="let s of states " [ngValue]="s">{{ s.label}}</option>
</select>",
});
export class FilterComponent {
private states = [
{
value: 'active',
label: 'Active',
},
{
value: 'done',
label: 'Done',
},
{
value: 'removed',
label: 'REMOVED',
}
];
private filterState = '';
selected() :void {
//this.filterState is still the initiated value
}
}
In the above case the "All" option is not shown and also whenever changing the option the ngModel it isn't updated.
Tried with value instead of ngValue , and also tried with a private filterState = 0; but same happens here