I am working with a dropdown and I want to make All Patients the default value.
<select [(ngModel)]="searchModel.careprovider">
<option [value]="0">All Pateints</option>
<option *ngFor="let user of practiceUsers" [value]="user._id.$oid">
{{user.dn}}
</option>
</select>
This is how my model is defined:
searchModel: any = { location: null, practice: null, name: '', careProvider: 0 };
The practiceUsers are set like this:
this._practice.getUsers(this.searchModel.practice).subscribe(result => {
this.practiceUsers = result;
this.searchModel.careProvider = 0;
});
Despite trying various methods, the default option always appears blank. I attempted adding an object to the this.practiceUsers
array after loading it, then setting the model value in different ways (both as a number and string), but nothing seems to work. In Angular 1, I would have used ng-options
, but with Angular 2, only examples of using ngFor
for dropdowns can be found.