angularjs选择所需的工作不NG选项 [英] angularjs select required not working ng-options
本文介绍了angularjs选择所需的工作不NG选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想,以确保用户提交表单前选择从一个选择框的值。
这与静态选择正确的工作;采用NG-选项填充通过模式选择,当失败然而
I am trying to ensure a user selects a value from a select box before submitting the form. This works correctly with static options; it however fails when populating the options via a model using ng-options
示例
http://plnkr.co/edit/wRqSCNskLo5c48jy4nQf
我使用AngularJS 1.2.9
I am using AngularJS 1.2.9
感谢您提前。
推荐答案
在您的例子改变必然选择以下修复所需的指令数据。我不知道到底为什么。
In your example changing the data bound select to the following fixes the required directive. I'm not sure why exactly.
<select ng-model="selectedValue1" ng-options="opt for opt in ['Mazda2','Maxda3']" required>
<option></option>
</select>
这篇关于angularjs选择所需的工作不NG选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文