angularjs指令适用于jsfiddle,但不适用于localhost

时间:2014-02-24 17:48:56

标签: javascript angularjs angularjs-directive

我尝试创建标签以在我的网站上使用YT视频。一切都适用于jsfiddle(http://jsfiddle.net/kertp/7GPBZ/8/),但在我的服务器上使用相同的代码是行不通的。查询是对localhost:5000 / {{url}},显然它失败了。我在哪里可以找到问题?

'use strict';

var module = angular.module('App')
  .controller('ProfileCtrl', function($scope) {
})
.directive('youtube', function ($sce) {
    return {
      restrict: 'EA',
      scope: {
          video: '@video'
      },
      link: function (scope) {
        scope.$watch('video', function (video_id) {
           scope.url = $sce.trustAsResourceUrl("http://www.youtube.com/embed/" + video_id);
        });
      },
      template: "<iframe width='560' height='315' src={{url}} frameborder='0' allowfullscreen></iframe>",
    };
});

我在index.html中使用ui-view类并使用profile.html中的标记

<youtube video="aOD43neIwO4"></youtube>

我正在使用angularjs版本1.2.11

0 个答案:

没有答案