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('rjHeader', function () {
return {
restrict: 'E',
template : function(e,a){
return '<script type="text/javascript" charset="utf-8" src="https://my.web.com/path/' + a.locale + '/some.js" ></script>';
}
};
});
And in html
<div rj-Header locale="en_US"></div>
When opening the page in browser, it correctly adds the intended script.
<script type="text/javascript" charset="utf-8" src="https://my.web.com/path/en_US/some.js" ></script>
But this doesn't actually loads this .js file. If I simple copy paste this line to my html then it works as expected. How can I inject script using custom angular directive?