In my view, I have:
<input my-directive
inputs="[userData.var1, userData.var2]"
type="checkbox"
ng-model="userData.myModel"
id="vegetarian"
class="v3-custom-checkbox" />
In the directive, I have:
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);
}
});
}
}
This gives me an error expression in attribute 'inputs' is non-assignable!
Angular version is 1.6.4.