Skip to content

Instantly share code, notes, and snippets.

@joshbuchea
Last active August 29, 2015 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshbuchea/5aa780b818a97d713247 to your computer and use it in GitHub Desktop.
Save joshbuchea/5aa780b818a97d713247 to your computer and use it in GitHub Desktop.
AngularJS Trusted Resource Filter
.filter('trusted', ['$sce', function ($sce) {
return function(url) {
return $sce.trustAsResourceUrl(url);
};
}])
@joshbuchea
Copy link
Author

If Strict Contextual Escaping (SCE) is enabled in your AngularJS app, you will need to whitelist the URL or wrap the URL with a call to $sce.trustAsResourceUrl. This filter is convenient way of wrapping the URL.

In your templates:

{{object.src | trusted}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment