I have a select with first option as hard coded one just to show the place holder and list of objects, on click of clear i need to reset the select to the first option, I am not able to do that here, is there a way ??
<select class="form-control" aria-placeholder="Select File" style=" margin-right:5px;padding:0px;width:400px" [(ngModel)]="ddlFileId" (change)="loadFiles($event.target.value)" [ngModelOptions]="{standalone: true}" >
<option [value]="''" disabled selected>Select File</option> // this will appear like a place holder
<option *ngFor="let file of AllFileIDS" [value]="file.FileID" [ngValue]="file.FileID">{{file.FileID}}</option>
</select>
I tried
this.ddlFileId = "";
My attempts
- Made the data source empty and re assigned it
- Gave a value instead of
""
to[(ngmodel)]
- i even added a flag and tried to assign it to [selected] it was stil not working
is there any way other way than making this a dictionary and adding first object into it with setting disabled property as a flag to it ?, thats what iam planning now.
Other SO questions didn't help me