Skip to content Skip to sidebar Skip to footer

Angular Setting $sce In Ng-repeat

I am trying to display videos in iframe, but nothing gets displayed even though I am getting the right embed link for it. I have tried testing it by just displaying the link and th

Solution 1:

Since I need to inject $sce dependency I wonder how to apply it to all the possible links in my controller. How would that function look?

I'd recommend a filter for this.

.filter( 'safeUrl', [
    '$sce'function($sce){
        returnfunction(url){
             //not sure which one you need herereturn$sce.trustAsUrl(url)
        }
    }
])

in your html

<iframesrc="{{article.external_media[0].url | safeUrl}}">

I advocate filters over controller methods only in I like to keep my controllers very lightweight. If something needs to be interpreted, I use a filter.

Post a Comment for "Angular Setting $sce In Ng-repeat"