Last active
December 22, 2015 03:29
-
-
Save petrjasek/6410488 to your computer and use it in GitHub Desktop.
sd checkbox directive
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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