如何在angularjs中播放视频?

时间:2015-07-22 08:54:26

标签: angularjs cordova ionic-framework

嗨我有一个项目列表,其中我显示的视频网址和图片网址如下所示

HTML代码

<div ng-app="myApp" ng-controller="myCtrl">
<div class="news_image" ng-repeat="image in items.media">
    <img ng-src="{{image.src}}" ng-if="image.type === 'img'" />
    <video ng-if="image.type === 'video'" width="320" height="240" controls>
      <source ng-src="{{image.src}}" type="video/mp4">
    </video>
</div>

和angular js code

angular.module('myApp', [])
.controller('myCtrl', function ($scope) {
$scope.items = {
    "media": [{
        "type": "img",
        "src": "http://images/2015/May/161887.jpg"
    }, {
        "type": "video",
        "src": "http:/video/2015/May/161887.mp4",
    }]
};

});

问题是图像工作正常但视频无效。我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

您的代码中存在拼写错误。视频src是错误的。

angular.module('myApp', [])
.controller('myCtrl', function ($scope) {
$scope.items = {
    "media": [{
        "type": "img",
        "src": "http://images/2015/May/161887.jpg"
    }, {
        "type": "video",
        "src": "http://video/2015/May/161887.mp4",
    }]
};
});