使用IMG NG-SRC显示不起作用的图像数组



我在显示图像数组时读取了一些使用NG-SRC的解决方案,但似乎无法正常工作。数组中只有1个项目接受要显示。有什么解决方案吗?我也尝试了 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重复,以查看您是否正在追求的效果。

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

最新更新