【发布时间】:2013-12-25 05:15:30
【问题描述】:
我创建了以下 AngularJS 指令来嵌入 youtube 视频:
// A Simple youtube embed directive
.directive('youtube', function() {
return {
restrict: 'EA',
scope: { code:'=' },
replace: true,
template: '<div style="height:400px;"><iframe style="overflow:hidden;height:100%;width:100%" width="100%" height="100%" src="http://www.youtube.com/embed/{{code}}" frameborder="0" allowfullscreen></iframe>'
};
});
当我从模板<youtube code="r1TK_crUbBY"></youtube> 调用它时,我收到以下错误:
错误:[$interpolate:noconcat] 插值时出错:http://www.youtube.com/embed/{{code}} 严格的上下文转义不允许在需要可信值时连接多个表达式的插值。见http://docs.angularjs.org/api/ng.$sce
我无法确定{{code}} 表达式中的指令有什么问题。
【问题讨论】:
标签: javascript angularjs youtube angularjs-directive