Skip to content

Instantly share code, notes, and snippets.

@szanata
Created December 29, 2015 15:47
Show Gist options
  • Save szanata/8e4bbe37006c701c26e0 to your computer and use it in GitHub Desktop.
Save szanata/8e4bbe37006c701c26e0 to your computer and use it in GitHub Desktop.
Angular trigger change for checkboxes on click.
App.directive('checkboxChange', function() {
return {
restrict: 'A',
require: '?ngModel',
scope:{
checkboxChange:'=checkboxChange'
},
link: function (scope, el, attrs, ngModel) {
console.log('jere')
el.on('click', function (){
if (typeof scope.checkboxChange === 'function'){
scope.checkboxChange(ngModel.$viewValue);
}
});
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment