angularjs指令中布尔值的绑定数组
我认为:angularjs指令中布尔值的绑定数组,angularjs,Angularjs,我认为: <input my-directive inputs="[userData.var1, userData.var2]" type="checkbox" ng-model="userData.myModel" id="vegetarian" class="v3-custom-checkbox" /> 在指令中,我有: myDirectives.directive('myDirective', func
<input my-directive
inputs="[userData.var1, userData.var2]"
type="checkbox"
ng-model="userData.myModel"
id="vegetarian"
class="v3-custom-checkbox" />
在指令中,我有:
myDirectives.directive('myDirective', function() {
return {
restrict: 'A',
require: 'ngModel',
scope: {
inputs: '='
},
link: function(scope, element, attrs, ngModel) {
scope.$watch(function () {
return ngModel.$modelValue;
}, function(newValue) {
if(newValue) {
for (var i = 0; i < scope.inputs.length; i++) {
scope.inputs[i]=false;
}
console.log(scope.inputs);
}
});
}
}
mydirections.directive('myDirective',function(){
返回{
限制:“A”,
要求:'ngModel',
范围:{
输入:'='
},
链接:功能(范围、元素、属性、模型){
范围:$watch(函数(){
返回ngModel.$modelValue;
},函数(newValue){
如果(新值){
对于(变量i=0;i
这给了我一个错误,属性“inputs”中的表达式是不可赋值的
角度版本是
1.6.4
请发布完整的指令代码,而不仅仅是链接