So unfortunately based on a ton of searching there isn't any way to do this with pure angular. Using "ng-include", a template based directive or even "ng-src" on a script tag all may even download the scripts but they won't run them by default.
Since I am guessing you don't want to modify the trip advisor code the best option I could find is to call the jQuery "getScript" something like:
$.getScript("//www.tripadvisor.com/WidgetEmbed-cdsratingsonlynarrow?amp;uniq=791&lang=en_US&border=true&locationId=2227230");
I took this and simplified it into a directive that looks like the following:
app.directive("widgit", function ($sce, $timeout) {
return {
link: function (scope, element, attrs) {
scope.$watch("attrs.widgit", function () {
$.getScript(scope[attrs.widgit].script);
element.append(angular.element(scope[attrs.widgit].widgit));
});
}
};
});
If you want to see this working take a look at the following plunker: http://plnkr.co/edit/QmxgcPujnjtqUgECeLC3?p=preview
One final really important thing is the script include from trip advisor actually just calls another script tag. From what I could determine you can't use this script directly - instead you have to manually follow that script tag to the actual value. In other words:
- Don't Use: - //www.jscache.com/wejs?wtype=cdsratingsonlynarrow&uniq=791&locationId=2227230&lang=en_US&border=true
- Instead: - //www.tripadvisor.com/WidgetEmbed-cdsratingsonlynarrow?amp;uniq=791&border=true&lang=en_US&locationId=2227230
All in all, I think that should get you what you are looking for. Best of luck!
MORE DETAILS
So based on a follow up, I added routes to the example and reproduced the issue again, this time with the ng-view. The basic problem here is still that the trip advisor code isn't getting run after the view is loaded. Essentially all that needs done to the previous is to add the following few lines of code (after the code renders):
if (window.taValidate) {
window.taValidate();
}
What you end up with after this is the following working plunker: http://plnkr.co/edit/fqQXnx0uyckuVkxOZq6n?p=preview.