【发布时间】:2015-02-16 14:11:57
【问题描述】:
我正在使用 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;
这可能意味着它正在对属性值进行字符串比较。
有什么方法可以解决这个问题并绑定属性(即使是在初始化期间的一次性绑定)?
【问题讨论】:
标签: angularjs binding angular-ui angular-ui-select