将范围值绑定到angular的ui-select中的ui-select-match属性

Iravanchi

我正在使用AngularUI的UI-Select在我的应用程序中创建丰富的选择,并且试图将allow-clear属性绑定到作用域上的函数或属性:

<ui-select ng-model="$parent.model" theme="bootstrap">
    <ui-select-match placeholder="..." allow-clear="$parent.allowClear">{{$select.selected.DisplayText}}</ui-select-match>
    <ui-select-choices repeat="opt.ID as opt in operators">
        {{opt.DisplayText}}
    </ui-select-choices>
</ui-select>

但是,无论我尝试什么,都无法使其正常工作。然后,在uiSelectMatch指令定义下的UI-Select源代码上找到以下代码:

    $select.allowClear = (angular.isDefined(attrs.allowClear)) ? (attrs.allowClear === '') ? true : (attrs.allowClear.toLowerCase() === 'true') : false;

这可能意味着它正在对属性值进行字符串比较。

有什么办法可以解决此问题并绑定属性(甚至在初始化期间进行一次绑定)?

伊利亚·卢兹亚宁

如果我答对了,您可以包装您的价值{{...}}以使其发挥作用,如下所示:

<ui-select-match placeholder="..." allow-clear="{{!!$parent.allowClear}}">{{$select.selected.DisplayText}}</ui-select-match>

看到一点演示

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

清除ui-select角度中的选定选项

Angular ui-select:如何仅将所选值绑定到ng-model

允许在ui-select中手动输入文本

angular- ui-select-如何将对象属性绑定到ng-model

在angular-ui-select多选模式中禁用选择的选项

Angular 2形式:将html select绑定到对象集合

Angular ui.select不绑定到ng-model

使用对象数组中的ID设置ui-select值

Material UI Multiple Select中的可删除筹码

ng-style在ui-select-match- AngularJs中不起作用

无法绑定到“值”,因为它不是“ ngx-select-dropdown”的已知属性

在angularjs ui-select中显示十六进制颜色

如何将Angular-Material Select字段的显示值绑定到ngModel

AngularJS:ui-select将数据绑定回select

React Hooks:UseRef无法从Material UI Select中识别事件

Blazor select绑定到列表中的值

将属性绑定到隔离范围中的对象属性

ng-repeat中的角度ui-select

嵌套指令和ui-select中的双向绑定

<ui-select> </ ui-select>标记在浏览器中引发错误

将ui-select标记与angular一起使用,将函数正式传递给属性标记

在ui-select中添加/删除焦点

仅限Angular $ filter select属性

无法在ui-select.js中的ctrl.getplaceholder处获取未定义或空引用的属性“长度”

无法在angularjs 1.5.8中的ui-select上输入文本

<ui-select> 的 ng-model 中的值与原生 <select> 不同

Angular ui-grid TypeError:无法读取未定义的属性“SELECT”

select angular中#select的解释

material-ui:需要帮助在 <Select> 中隐藏下拉图标