使用 img ng-src 显示图像数组不起作用
Using img ng-src to display array of image not working
我阅读了一些在显示图像数组时使用 ng-src 的解决方案,但它似乎不起作用。数组中只有一项接受显示。有什么解决办法吗?我也试过 img [src]
但没有一个有效。
这是我试过的
angular.module('selectExample', [])
.controller('ExampleController', ['$scope', function($scope) {
$scope.register = {
regData: {
branch: {},
},
names: [{
name:"narquois",
image:[
"https://picsum.photos/200",
"https://picsum.photos/200/300/?random"]
},
{
name:"velvet",
image:[
"https://picsum.photos/200"]
}],
};
}]);
img{
width:70px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.5/angular.min.js"></script>
<div ng-app="selectExample" ng-controller="ExampleController">
<table id="example" width="100%">
<thead>
<tr align="center">
<th>Name</th>
<th>Image</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="person in register.names">
<td align="center">{{ person.name }}</td>
<td align="center"><img ng-src="{{ person.image }}"></td>
</tr>
</tbody>
</table>
</div>
您目前没有循环播放不同的图像。
尝试用这个替换你的 ng-repeat 看看这是否是你想要的效果。
<tr ng-repeat="person in register.names track by $index">
<td align="center">{{ person.name }}</td>
<td align="center">
<img ng-repeat="image in person.image" ng-src="{{image}}" />
</td>
</tr>
我阅读了一些在显示图像数组时使用 ng-src 的解决方案,但它似乎不起作用。数组中只有一项接受显示。有什么解决办法吗?我也试过 img [src]
但没有一个有效。
这是我试过的
angular.module('selectExample', [])
.controller('ExampleController', ['$scope', function($scope) {
$scope.register = {
regData: {
branch: {},
},
names: [{
name:"narquois",
image:[
"https://picsum.photos/200",
"https://picsum.photos/200/300/?random"]
},
{
name:"velvet",
image:[
"https://picsum.photos/200"]
}],
};
}]);
img{
width:70px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.5/angular.min.js"></script>
<div ng-app="selectExample" ng-controller="ExampleController">
<table id="example" width="100%">
<thead>
<tr align="center">
<th>Name</th>
<th>Image</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="person in register.names">
<td align="center">{{ person.name }}</td>
<td align="center"><img ng-src="{{ person.image }}"></td>
</tr>
</tbody>
</table>
</div>
您目前没有循环播放不同的图像。
尝试用这个替换你的 ng-repeat 看看这是否是你想要的效果。
<tr ng-repeat="person in register.names track by $index">
<td align="center">{{ person.name }}</td>
<td align="center">
<img ng-repeat="image in person.image" ng-src="{{image}}" />
</td>
</tr>