我正在尝试重复一组图像路径,但图像没有加载。尝试过ng-src和src,都没有。
HTML文件:
<div ng-app="homeIndexApp">
<div ng-controller="homeIndexController">
<div ng-repeat="x in pics">
<img ng-src="{{x.source}}">
</div>
</div>
</div>
js file:
var homeIndex = angular.module('homeIndexApp', []);
homeIndex.controller('homeIndexController', function ($scope) {
$scope.pics = [{ source: 'images/slides/Slide4.png' },
{ source: 'images/slides/Slide5.png' },
{ source: 'images/slides/Slide1.png' },
{ source: 'images/slides/Slide2.png' },
{ source: 'images/slides/Slide3.png' }
];
});
但是,当我在浏览器中检查元素时,我可以将鼠标悬停在src标记上并查看图像缩略图:
<img ng-src="images/slides/Slide4.png" src="images/slides/Slide4.png">
为什么他们不出现在网站上?这些代码有什么问题?
答案 0 :(得分:0)
在此示例中正常工作:
var homeIndex = angular.module('homeIndexApp', []);
homeIndex.controller('homeIndexController', function ($scope) {
$scope.pics = [
{ source: '//i.imgur.com/vM1snTA.jpg' },
{ source: '//i.imgur.com/OB2vpNi.jpg' },
];
});
&#13;
<script src="//unpkg.com/angular/angular.js"></script>
<div ng-app="homeIndexApp">
<div ng-controller="homeIndexController">
<div ng-repeat="x in pics">
<img ng-src="{{x.source}}" height=100>
</div>
</div>
</div>
&#13;