Javascript 角度选择默认选项,需要ng
我有以下代码:Javascript 角度选择默认选项,需要ng,javascript,angularjs,Javascript,Angularjs,我有以下代码: <select id="document" ng-model="document.Id" ng-options="option.Id as option.Name for option in documents" ng-required="IsDocumentRequired"> <option value="">Please Select Document</option> </select> 请选择文档 问题是我不
<select id="document" ng-model="document.Id" ng-options="option.Id as option.Name for option in documents" ng-required="IsDocumentRequired">
<option value="">Please Select Document</option>
</select>
请选择文档
问题是我不希望这个默认值(“请选择文档”)在设置为true时满足ng required标志
总之,我希望强制用户选择默认选项以外的选项
感谢当您的值为”
时,它不满足select的ng必需
,select的必填字段验证仅在select选项不等于空时通过,它是这样设计的
请参阅plunker演示,当您的值为”
时,它不满足select的ng required
,select的必填字段验证仅在select选项不等于空时通过,它是这样设计的
请参阅plunker演示,不要使用
<option value="">Please Select Document</option>
请选择文档
因此,它不会显示它,用户应该从列表中选择一个项目不要使用
<option value="">Please Select Document</option>
请选择文档
因此它不会显示它,用户应该从列表中选择一项,您可以测试所选值(在您的情况下,我建议您将“-1”作为“请选择文档”的值) 如果用户未选择其他值,则将其视为错误
或者查看中的响应,您可以测试所选的值(在您的情况下,我建议您将“-1”作为“请选择文档”的值) 如果用户未选择其他值,则将其视为错误
或者查看中的响应,这是否现在不起作用?
value=”“
应使该选项不满足ng所需的。@bboyk请参见plunker演示仅使用所需的。这里没有使用ng required
的要求。现在不行吗?value=”“
应使该选项不满足ng所需的。@bboyk请参见plunker演示仅使用所需的。这里没有使用ng required
的要求。谢谢,但是我需要选择框中的占位符文本谢谢,但是我需要选择框中的占位符文本