While this explanation may be lengthy, I appreciate your patience as I try to articulate the issue at hand. The error I'm currently encountering is as follows:
Error: [$interpolate:noconcat] Error while interpolating:
Strict Contextual Escaping disallows interpolations that concatenate multiple expressions when a trusted value is required.
See http://docs.angularjs.org/api/ng.$sce
Despite extensively reading through the documentation, I have yet to discover a solution for my predicament.
The scenario involves me utilizing $http.get on a private online source containing data structured similarly to a JSON file (data cannot be modified). Here's an example snippet of how the data appears:
...
"items": [
{
"kind": "youtube#searchResult",
"etag": "\"N5Eg36Gl054SUNiWWc-Su3t5O-k/A7os41NAa_66TUu-1I-VxH70Rp0\"",
"id": {
"kind": "youtube#video",
"videoID": "MEoSax3BEms"
},
},
{
"kind": "youtube#searchResult",
"etag": "\"N5Eg36Gl054SUNiWWc-Su3t5O-k/VsH9AmnQecyYBLJrl1g3dhewrQo\"",
"id": {
"kind": "youtube#video",
"videoID": "oUBqFlRjVXU"
},
},
...
My objective is to interpolate the videoId of each item into an HTML iframe that embeds the respective YouTube video. In my controller.js file, I'm setting the promise object after the $http.get request like so:
$http.get('privatesource').success(function(data) {
$scope.videoList = data.items;
});
As a result, the variable "$scope.videoList" is now linked to data.items, which consists of numerous video elements. Within my HTML file, I can access the videoID for each video using:
<ul class="videos">
<li ng-repeat="video in videoList">
<span>{{video.id.videoID}}</span>
</li>
</ul>
This successfully displays all the video IDs. However, attempting to concatenate these values with a URL such as proves unsuccessful.
<div ng-repeat="video in videoList">
<iframe id="ytplayer" type="text/html" width="640" height="360"
ng-src="https://www.youtube.com/embed/{{video.id.videoId}}"
frameborder="0" allowfullscreen></iframe>
</div>
Is there a way to effectively interpolate the videoID into the YouTube URL? Despite trying to whitelist it using $sceDelegateProvider as shown below, the issue persists:
$sceDelegateProvider.resourceUrlWhitelist([
'self',
'https://www.youtube.com/**']);
Any assistance offered would be greatly appreciated. Thank you!