Reputation: 537
I want to set a default value in my dropdown, but it seems I'm not able to do so.
<div class="form-group">
<select id="interfaceType" (ngModelChange)="onChange($event)" [(ngModel)]="interfacengmodel" #interfaceType="ngModel"
name="interfaceType" class="form-control" required >
<option value="" disabled selected>Choose Interface Name</option>
<option *ngFor="let interface of interfaceList" [value]="interface.interfaceName">{{interface.interfaceName}}
</option>
</select>
{{interfaceLocation}}
</div>
I'm new to angular.
Thanks,
Upvotes: 0
Views: 6831
Reputation: 774
set the value of property interfacengmodel that you want to selected as default
Upvotes: 0
Reputation: 41445
set the interfacengmodel
as empty string
public interfacengmodel: UrType = "";
Upvotes: 1
Reputation: 32535
<select id="interfaceType" (ngModelChange)="onChange($event)" [(ngModel)]="interfacengmodel"
Just set the default value (whatever it is ) to interfacengmodel
in your component and it will become selected
Upvotes: 2