Francisc Francisc - 3 months ago 38
AngularJS Question

$sce.trustAsResourceUrl() globally

How can I do something like this:


Globally, like in the main app's
functions so that any iFrames, img src etc that have
will work?

Docs are rather poor at explaining this.


I just read your comment from the previous answer. Not sure if you found a solution yet. Seems you are looking for a whitelist type of thing. I recently found this out that there's a whitelist function for $sce.

Taken from the AngularJS docs for $sceDelegateProvider:

angular.module('myApp', []).config(function($sceDelegateProvider) {
   // Allow same origin resource loads.
   // Allow loading from our assets domain.  Notice the difference between * and **.

With this you can do string interpolation in iframes like this:

<iframe ng-src="{{ '' + url_asset }}"></iframe>