在我的角度應用程序中,我有嵌入式視頻列表,我想在我的視圖中顯示此嵌入式視頻。我下面的代碼給出:在angularjs中嵌入視頻
角的ArrayList
.filter('unsafe', function() {
return function(url) {
var newUrl = url.replace(/</g, "<").replace(/>/g, ">");
return newUrl ;
}
})
controller('', function($scope) {
$scope.videoLink = [
'<iframe width="560" height="315" src="https://www.youtube.com/embed/cwXfv25xJUw" frameborder="0" allowfullscreen></iframe>',
'<iframe width="560" height="315" src="https://www.youtube.com/embed/cKJvScGB5Ak" frameborder="0" allowfullscreen></iframe>',
'<iframe width="560" height="315" src="https://www.youtube.com/embed/W9xtFtOA7_8" frameborder="0" allowfullscreen></iframe>'
];
});
HTML視圖
<div ng-repeat="url in videoLink">
<!-- {{url}} --> <!-- only show plain text -->
<!-- <div ng-html-bind='url'></div> --> <!-- nothing shown -->
<!-- {{url | unsafe}} --> <!-- only show plain text -->
</div>
我該如何解決這個問題???