使用angularjs在标记<video>中显示视频

时间:2016-03-02 16:04:10

标签: javascript angularjs html5

查看:

<div class="list card" ng-repeat="x in content.spells">
....
    <video width="320" height="240" ng-src="{{(getIdVideo(content.id) | trusted )}}"   controls>
          Seu navegador não suporta o elemento <code>video</code>.
    </video>
....
</div>

控制器:

$scope.getIdVideo = function(videoId){
    videoId = videoId.toString();
    for (var i=0; i<=4; i++){
      if (videoId.length != 4){
        //videoId = videoId.push('0');
        videoId = "0"+videoId;
      }

    }

    return 'http://cdn.leagueoflegends.com/champion-abilities/videos/mp4/'+videoId+'_02.mp4';
  };

同一视频显示4次。 The same video is shown 4 times

我调用此函数getIdVideo(),根据id返回视频。我的方式显示相同的视频4次。问题是,我需要向每个id显示4个视频,只需更改,从02到05,&#34; _&#34;在网址:

  

HTTP:/cdn.leagueoflegends.com/champion-abilities/videos/mp4 /&#39 + + VIDEOID&#39; _02.mp4

我该怎么做?

1 个答案:

答案 0 :(得分:1)

从外观上看,id似乎是内容。但您需要在id上设置content.spells

然后你可以使用

    <video width="320" height="240" ng-src="{{(getIdVideo(x.id) | trusted )}}"   controls>