Skip to content

Instantly share code, notes, and snippets.

@petrjasek
Last active December 22, 2015 03:29
Show Gist options
  • Save petrjasek/6410488 to your computer and use it in GitHub Desktop.
Save petrjasek/6410488 to your computer and use it in GitHub Desktop.
sd checkbox directive
<input type="checkbox" ng-model="item.selected" sd-custombox />
directive.js:
return {
require: '?ngModel',
link: function($scope, element, attrs, ngModel) {
element.click(function() {
$scope.$apply(function() {
ngModel.$serViewValue(!ngModel.$getViewValue());
});
});
// init
ngModel.$render(function() {
element.attr('checked', ngModel.$getViewValue());
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment