AngularJS选择所需验证

AngularJS选择所需验证,angularjs,select,required,Angularjs,Select,Required,下面是我的代码片段。我想使用angular验证我的选择框 <form name="myForm"> <select name="category_1" ng-model="catid" id="category_1" ng-options="category.catid for catid in categories" required> <option value="" selected=""></option> <o

下面是我的代码片段。我想使用angular验证我的选择框

<form name="myForm">
  <select name="category_1"  ng-model="catid" id="category_1" ng-options="category.catid for catid in categories" required>
    <option value="" selected=""></option>
    <option value="1">music</option>
    <option value="2">internet</option>
  </select>
  <button ng-disabled="!myForm.$valid" ng-click="uploadPic(picFile)">Submit</button>
</form>

音乐
互联网
提交
但无法提交表单我在chrome中遇到此错误,并且提交按钮不起作用

名为class='category\u 0'的无效表单控件不可聚焦


这是

问题不在于选择框,可能问题在于您有另一个选择框(名称为
category\u 0
)或其他输入字段(名称为
category\u 0
),它具有required属性,并且隐藏或不可见


因此,当您尝试提交表单时,它会尝试聚焦表单,但这是不可能的。确保名为
category\u 0
的元素不在
ng hide
块内,也不在
ng show
条件为
false
category.catid中。

category.catid for categories
:这是无效的。什么是
category
?如何使其有效?假设categories
中的对象具有名为catid的字段,则categories中category的
category.catid将有效。你为什么不看文档:?因为我的英语不够,我已经试过了,现在我不能点击提交按钮