Answer the question
In order to leave comments, you need to log in
How to apply jQuery plugin on angularjs?
Can you tell me how to apply jQuery plugin on angularjs?
Directive code:
app.directive('ibaModel', function () {
return {
restrict: 'A',
priority: 1010,
link: function (scope, element, attrs) {
// debugger;
var el = $(element);
el.attr('id', scope.config.templateId);
el.iba_model('init', {id: scope.config.templateId});
}
};
});
Answer the question
In order to leave comments, you need to log in
1. Using jquery and angular is not the best idea, they have completely different ideologies. But if "you need it and that's it", then
2. Angular knows nothing about the events that took place "outside the angular world". Your
el.iba_model('init', {id: scope.config.templateId});explicitly adds something to the DOM and for Angular to know about it You need to call $digest (or the safer $apply function) at this point
You have not declared a local scope
app.directive('ibaModel', function () {
return {
restrict: 'A',
priority: 1010,
scope: {
config:{
templateId:'='
}
},
link: function (scope, element, attrs) {
// debugger;
var el = $(element);
el.attr('id', scope.config.templateId);
el.iba_model('init', {id: scope.config.templateId});
}
};
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question