In my view
<input my-directive inputs="[userData.var1, userData.var2]" type="checkbox" ng-model="userData.myModel" id="vegetarian" class="v3-custom-checkbox" />
in the directive
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
Source: AngularJS
from Angular Questions https://angularquestions.com/2017/10/05/bind-array-of-boolean-in-angularjs-directive/
via @lzomedia #developer #freelance #web #lzomedia.com
No comments:
Post a Comment