码迷,mamicode.com
首页 > 其他好文 > 详细

[Angular2 Form] Build Select Dropdowns for Angular 2 Forms

时间:2016-09-30 01:01:08      阅读:332      评论:0      收藏:0      [点我收藏+]

标签:

Select Dropdowns in Angular 2 a built with select and option elements. You use *ngFor to loop through your values and create options and use ngModel to keep track of the value as it changes.

 

<form #formRef="ngForm">
    <select name="location" [ngModel]="locations[0]">
        <option 
            *ngFor="let location of locations"
            [value]="location">
            
            {{location}}
            
        </option>
    </select>
</form> 

 

[Angular2 Form] Build Select Dropdowns for Angular 2 Forms

标签:

原文地址:http://www.cnblogs.com/Answer1215/p/5921106.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!