Reputation: 9184
I'm using angularJS 1.6 directive to add some jQuery libs. Now i'm using it so:
let SomeDirective = function ($timeout) {
'ngInject';
return {
restrict: 'A',
link: function (scope, element, attrs) {
$timeout(function () {
element.somePlugin(JSON.parse(attrs.params));
});
}
};
};
export default SomeDirective;
due to that fact, that I set some-directive on html object, which is loaded from the server, i think angular didn't understand, when apply this directive...
But i think this approach is strange and ugly... How can i fix this directive?
By the way, adding in scope isLoaded
variable (and watch it in directive) didn't resolve my problem
Upvotes: 0
Views: 1512
Reputation: 220
You can use $scope.$evalAsync(). Refer https://docs.angularjs.org/api/ng/type/$rootScope.Scope.
Upvotes: 2