Forked from robhimslf/angularjs-scedelegate-whitelist
Created
October 19, 2015 19:10
-
-
Save WagnerMoreira/0ccb1b41d5a9b621fc33 to your computer and use it in GitHub Desktop.
Populating AngularJS's resource URL whitelist enables the use of remotely located views and partials hosted on a different domain (e.g., Amazon S3).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Standard AngularjS bootstrap code. | |
*/ | |
var app = angular.module('remote-partials-views', | |
['ui.router', | |
'ngResource', | |
'ngSanitize']); | |
/* | |
* AngularJS is good enough to come with a whitelist for resource URLs. It just | |
* needs to be populated. It's pretty straightforward, as it's a simple array | |
* list of whitelisted values. You might notice the first entry is "self." This | |
* is just shorthand for whatever domain the AngularJS site is executing on. | |
*/ | |
app.config(['$sceDelegateProvider', function($sceDelegateProvider) { | |
$sceDelegateProvider.resourceUrlWhitelist([ | |
'self', | |
'https://remote.domain.com/**' | |
]); | |
}]); |
Thank you, that works for me.
Pro Tip: It seems these URLs only match if they are added using lower-case as above. (I'm on Angular 1.4.2 so perhaps that restriction has been relaxed in later versions).
Please how can i use the angularjs-scedelegate-whitelist, where must i put this file
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice, thanks!