Hi,
Short description :
I would like to apply a jQuery plugin after ng-repeat apply on a directive.
Long description :
HTML :
<select data-placeholder="Choose..." ng-model="groups" multiple chosen>
</select>
I tried by compiling myself and using $apply() before I call the plugin. It works but
angularjs thow an exception on $apply() saying that apply is already under processing. Regarding documentation it seems normal.
directives.directive('chosen', function($compile){
return {
restrict:'A',
link: function(scope, element, attrs)
{
//First we need to compile inside the <select/> tag to ensure that <option ng-repeat /> is compiled
$compile(element.contents())(scope);
//Then we tell AngularJS to reflect it in the DOM
scope.$apply(); //This thow an exception (how to do in an other way?)
//Then we apply our Chosen jQuery plugin
$(element).chosen();
}
}
});
So I tried using transclude property (without $compile()and without $apply()) but it doens't work : options elements are not visible for the plugin 'chosen'. So the result is an empty list.
I would like to tell angularjs to compile ng-repeat before I call the jQuery plugin. I was thinking that transclude would be the solution but it seems that I missed something here...
Any good tips on this?
Thank you,