当 typeahead-editable 为 false 时设置输入无效 [英] Set input invalid when typeahead-editable is false

查看:29
本文介绍了当 typeahead-editable 为 false 时设置输入无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 typeahead 的 UI Bootstrap 组件,我想强制选择以验证我的表单.

I'm using typeahead's UI Bootstrap component and I want to force the selection to validate my form.

typeahead-editable设置为false并且用户输入bad"时,是否可以将其配置为将输入设置为无效?value 或者我应该为此编写一个指令(但如何)?

Is it possible to configure it to set the input invalid when typeahead-editable is set to false and the user enters a "bad" value or I should write a directive for this (but how)?

推荐答案

typeahead 指令来自 http://angular-ui.github.io/bootstrap/ 已经支持将输入限制为匹配(换句话说,人们可以绑定到模型中仅作为匹配项在 typeahead 弹出窗口中可用的值).您只需设置 typeahead-editable='false' 属性即可完成此操作.

The typeahead directive from http://angular-ui.github.io/bootstrap/ has already support for limiting inputs to matches (in other words, people can bind to model only values available as matches in the typeahead popup). You can do this by simply setting typeahead-editable='false' attribute.

请注意,将此属性设置为 false不会阻止人们输入无效值.它只会确保相应的输入被标记为无效,并且提供的值未绑定到模型.

Please note that setting this attribute to false will not prevent people from typing-in invalid values. It will just make sure that a corresponding input is marked as invalid and a provided value is not bound to the model.

这篇关于当 typeahead-editable 为 false 时设置输入无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆