Skip to content

Instantly share code, notes, and snippets.

@clemgrim
Created December 3, 2015 09:07
Show Gist options
  • Save clemgrim/5eba52cae08ded2ee8bf to your computer and use it in GitHub Desktop.
Save clemgrim/5eba52cae08ded2ee8bf to your computer and use it in GitHub Desktop.
module.exports = /*@ngInject*/ function () {
return {
restrict: 'AE',
link: function postLink (scope, elm, attrs) {
var opt = {};
if (attrs.nullable != undefined) {
opt.allow_single_deselect = true;
}
scope.$watch(attrs.ngModel, function () {
if (elm.data('chn')) {
elm.trigger('chosen:updated');
} else {
elm.chosen(opt);
elm.data('chn', true);
}
});
}
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment