pra*_*pds 0 angularjs ui-select angular-ui-select
Lib链接:https://github.com/angular-ui/ui-select
有没有办法在multiSelect中阻止用户编辑?
我想允许用户只清除以前选择的数据,但是如何阻止他输入ui-select中的任何自由文本
http://plnkr.co/edit/juqoNOt1z1Gb349XabQ2?p=preview
<ui-select multiple ng-model="multipleDemo.colors" theme="select2" ng-disabled="disabled" style="width: 300px;">
<ui-select-match placeholder="Select colors...">{{$item}}</ui-select-match>
<ui-select-choices repeat="color in availableColors | filter:$select.search">
{{color}}
</ui-select-choices>
</ui-select>
Run Code Online (Sandbox Code Playgroud)
参考上面的代码和plunker,目前在ui-select"蓝色,红色"颜色被选中,用户可以清除这些值,但如果用户试图在ui中输入一些文本,请选择允许修改,
"但我的要求是阻止用户在该字段中输入此类文本."
提前致谢.
防止在选择框中输入
可以使用onkeypress属性的字母
现场代码http://plnkr.co/edit/jE0qBpewzvHG5oamB7vQ?s=TIKKc2Zmyq5lcvXI&p=preview
<ui-select multiple ng-model="multipleDemo.colors" onkeypress="return false;" theme="select2" ng-change="call()" ng-disabled="disabled" style="width: 300px;">
<ui-select-match placeholder="Select colors...">{{$item}}</ui-select-match>
<ui-select-choices repeat="color in availableColors | filter:$select.search">
{{color}}
</ui-select-choices>
Run Code Online (Sandbox Code Playgroud)
已选择:{{multipleDemo.colors}}
| 归档时间: |
|
| 查看次数: |
4687 次 |
| 最近记录: |