Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
angularjs指令中布尔值的绑定数组_Angularjs - Fatal编程技术网

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

请发布完整的指令代码,而不仅仅是
链接