Skip to content

Instantly share code, notes, and snippets.

@umar-webonise
Created March 5, 2015 09:15
Show Gist options
  • Save umar-webonise/73641a253a03d405e64e to your computer and use it in GitHub Desktop.
Save umar-webonise/73641a253a03d405e64e to your computer and use it in GitHub Desktop.
chonse jquery and angular js directive
TreeniApp.directive('chosen', function() {
var linker = function(scope, element, attr) {
// update the select when data is loaded
scope.$watch(attr.chosen, function(oldVal, newVal) {
element.trigger('chosen:updated');
});
// update the select when the model changes
scope.$watch(attr.ngModel, function() {
element.trigger('chosen:updated');
});
element.chosen();
};
return {
restrict: 'A',
link: linker
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment