【发布时间】:2014-02-25 11:04:33
【问题描述】:
我正在尝试创建自定义输入指令,它将覆盖复选框输入的默认行为。我似乎找不到阻止默认复选框输入指令执行的解决方案。
我尝试只装饰输入,自定义指令的优先级设置为 0。
<input type="checkbox" my-custom-directive="0" ng-model="MyList" />
我也尝试过使用模板并替换不同的元素类型。
<div my-custom-directive="0" ng-model="MyList"></div>
// part of directive object
return {
restrict: 'A',
template: '<input type="checkbox" />',
replace: true,
terminal: true,
priority: 0, ...
}
最终我要做的是将复选框输入绑定到数组,并创建行为,如果某个值是数组的成员,则将检查输入,否则将不检查。此外,如果用户选中输入框,指令会将提到的值添加到数组中。
【问题讨论】:
标签: angularjs angularjs-directive