Created
March 5, 2015 09:15
-
-
Save umar-webonise/73641a253a03d405e64e to your computer and use it in GitHub Desktop.
chonse jquery and angular js directive
This file contains 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
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