2016-07-24 3 views
0

私の要件は、ビデオ、画像、またはメモ用のテンプレートを作成することです。だから、私はビデオのためのディレクティブを作成し、YouTubeのURLを埋め込みます。エラーが表示されず、コンソールに正しいURLが表示されます。しかし、UIは空白になっています。youtubeのURLを含むAngularJsの指示

指令

<ve-iframe video="item"></ve-iframe> 

app.directive('veIframe', function($compile, $sce){ 
     var linker = function(scope, element, attr) { 
      var youtubeUrl= 'http://www.youtube.com/embed/'; 
      var embed = youtubeUrl+scope.video.id.videoId; 
      console.log(embed); 
      var template = '<iframe id="player" type="text/html" width="520" height="300" ng-src="{{embed}}" frameborder="0"></iframe>'; 
      element.html(template).show(); 

      $compile(element.contents())(scope); 
     } 
     return { 
      restrict: 'E', 
      link: linker, 
      scope: { 
       video: '=' 
      } 
     } 
    }); 
+0

ホワイトリストのリソースはありましたか? – dfsq

答えて

0

私のミスは、コードの行の下に問題

scope.embed = $ sce.trustAsResourceUrl(youtubeUrl + scope.video.id.videoId)固定。

関連する問題