Test user
Test user

Reputation: 459

how to play video in angularjs?

hi i have a list of items in that both video url and image url i am displaying that as below

HTML code

<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>

and 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",
    }]
};

});

The problem is the images are working properly but the video is not working. how can i fix this?

Upvotes: 0

Views: 958

Answers (1)

dhavalcengg
dhavalcengg

Reputation: 4713

There is a typo in your code. Video src is wrong.

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",
    }]
};
});

Upvotes: 1

Related Questions