Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
AngularJS Trusted Resource Filter
.filter('trusted', ['$sce', function ($sce) {
return function(url) {
return $sce.trustAsResourceUrl(url);

This comment has been minimized.

Copy link
Owner Author

joshbuchea commented Jan 2, 2015

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
You can’t perform that action at this time.