Francisc Francisc - 1 year ago 240
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.

Answer Source

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>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download