Created
May 24, 2014 05:35
-
-
Save robhimslf/75de12c966a10308c6d7 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/**' | |
]); | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment