$sce.trustAsResourceUrl() globally

后端 未结 4 2195
南笙
南笙 2020-11-30 01:38

How can I do something like this: $sce.trustAsResourceUrl(\'URL_HERE\');

Globally, like in the main app\'s config() or run() f

4条回答
  •  猫巷女王i
    2020-11-30 02:24

    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) {
     $sceDelegateProvider.resourceUrlWhitelist([
       // Allow same origin resource loads.
       'self',
       // Allow loading from our assets domain.  Notice the difference between * and **.
       'http://srv*.assets.example.com/**']);
     })
    

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

    
    

提交回复
热议问题