【发布时间】:2017-04-02 22:00:28
【问题描述】:
我想将模型值绑定到所选项目
<select id="hours" ng-model="v.T_Hour">
<option ng-repeat="n in [].constructor(24) track by $index" ng-selected="{{$index==v.T_Hour}}" value="{{$index}}">{{$index>9?$index:"0"+$index}}:00</option>
</select>
我希望在页面加载后,在 select 中选择模型“v.T_Hour”的值,我在控制器中分配模型的值,当我查看生成的 HTML 时,我看到该值被选中在 HTML 代码中,但在 select 控件中没有选中,并且 select 控件显示一个空项。
【问题讨论】:
标签: angularjs model ng-repeat selected