Skip to content

Instantly share code, notes, and snippets.

@robhimslf
Created May 24, 2014 05:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save robhimslf/75de12c966a10308c6d7 to your computer and use it in GitHub Desktop.
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).
/*
* 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