gpt4 book ai didi

javascript - 带有 Chrome 的 AngularJS 不显示 Mp4 视频

转载 作者:行者123 更新时间:2023-11-28 21:43:22 26 4
gpt4 key购买 nike

如果我对 src 使用 AngularJS 变量,我很难理解为什么我的视频没有显示。如果我直接使用 src="img/test1.mp4",它就可以工作。如果我想在 HTML 中显示 {{camera[0].video}},我已经正确显示了“test1”。感谢您的帮助。这是代码的一部分:

app.controller('appCtrl', function($scope) {

$scope.camera = [{
id: "1",
video: "test1"
},
{
id: "2",
video: "test2"
}];
});
<div class="container-fluid" ng-controller="appCtrl">
<video width="250" height="200" controls autoplay>
<source src="img/{{camera[0].video}}.mp4" type="video/mp4">
</video>
</div>

最佳答案

<script>

var app = angular.module('App', [])

app.controller('appCtrl', function($scope) {
$scope.path = "img/test1.mp4";
$scope.changePath = function() {
$scope.path = "img/test2.mp4";
$scope.$apply;
}

});

</script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body ng-app="App">
<div ng-controller="appCtrl">
<div>
<button type="button" ng-click="changePath()">Change Video</button>
</div>
<div>
<video width="480" height="280" controls autoplay>
<source ng-src="{{path}}" type="video/mp4">
</video>
</div>
</div>
</body>

关于javascript - 带有 Chrome 的 AngularJS 不显示 Mp4 视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40154504/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com