I'm having trouble getting my head around showing iFrames in my Angular app. My users are allowed to enter a YouTube URL and my app will convert this straight to a video.
Of course, Angular won't allow this directly so you have to explicitly "trust" the contents so I use this to get it to show the iframe:
$sce.trustAsResourceUrl(url_of_video)
However, how do I get back? I want to be able to send the URL to my back-end but in this sanitized form it's no longer the original url string.
UPDATE:
Experimenting with this and came up with this code:
angular.forEach($scope.task.items, function(item) {
item.data = $sce.getTrustedResourceUrl(item.data); //this gets rejected by $sce
item.data2 = $sce.getTrustedResourceUrl(item.data); //this is accepted and I'm free to POST the url
});
I've noticed that I can create a new name/value pair in the array and assign it the original url but if I try to assign the item.data with the trusted form of the sanitized data then it rejects it! Hmmmmm! Why is this?
Any ideas?
UPDATE 2 I decided to create two versions of the data, one for the front end (which I "trusted" with $sce) and one for the back. This appears to have solved my issue for the moment.