Bind And Fetch Dropdown List Value In Typescript And Angular2
This question was asked many times and couldn't help me with my problem. Not sure whats wrong with the approach and hope some fresh 'eyes' Here is my dropdownlist binding in HTML:
Solution 1:
try below,
<select [(ngModel)]="selectedObject">
<option *ngFor="let p of programs"
[ngValue] = "p"
[selected]="p.programName == selectedObject.programName"
>
{{p.programName}}
</option>
</select>
Check this Plunker!!
Hope this helps!!
Solution 2:
Basically, the problem is when declaring [ngModel]. It should be within [(ngModel)] which was missed in my original problem. :)
Thanks a lot to Madhu Ranjan for help on the fix !
After correcting (ngModel) able to bind and fetch successfully.
<select [**(ngModel)**]="selectedObject"><option *ngFor="let p of programs"value= {{p.programName}}>{{p.programName}}</option>
</select>
Post a Comment for "Bind And Fetch Dropdown List Value In Typescript And Angular2"