How To Load A Script Using Custom Angular Directive?
I am trying to load a script in my custom angular directive. Right now, it is simply adding script tag in DOM but it is not loading it. angular.module('myApp') .directive('rjHe
Solution 1:
Something seems a little wrong here, but if you really wanted to do this you could just append a script tag to your directive's element:
app.directive('loadDirective', function() {
return {
restrict: 'E',
link: function($scope, $el) {
var script = document.createElement('script');
script.src = '//cdnjs.cloudflare.com/ajax/libs/emojione/1.3.0/lib/js/emojione.min.js'$el.append(script);
}
}
});
Post a Comment for "How To Load A Script Using Custom Angular Directive?"