Previously, I used $sce.trustAsHtml(aString) to inject a string (eg, ...) to a template
I found a solution but might have gone a little too far. I created a script directive instead which will put the not-loaded script to the head of document. Something like this:
app.directive('script', function() {
return {
restrict: 'E',
scope: false,
link: function(scope, elem, attr) {
var scriptNode = document.createElement('script');
scriptNode.src = attr.src;
scriptNode.type = 'text/javascript';
document.head.appendChild(scriptNode);
}
};
});
But, this obviously has few limitations including the src must be some absolute path. (Can overcome that but it would be dirtier..)
I have put the sample HTML file somewhere I can tweak a little and use it to come up with this working plnkr