无法设置图像源角度js

时间:2015-07-23 09:40:12

标签: angularjs

ng-src标记没有获取值,也会出错。请给我解决方案

控制器:

for(var i =1 ;i<=5; i++){
   $scope["ValueField" + i] = i;
   $scope["PerformanceStatusImage" + i] = "../CSS/down-icn.png";
}

HTML:

<tr >
   <td ng:repeat="id in [1,2,3,4,5]">
       <label ng-bind="ValueField{{id}}"></label>
        <img ng-src ="{{PerformanceStatusImage{{id}}}}" ></img>
   </td>
</tr>

1 个答案:

答案 0 :(得分:0)

您正在使用PerformanceStatusImage1,PerformanceStatusImage2,PerformanceStatusImage3,PerformanceStatusImage4不同的对象,您需要在其中执行迭代

例如: -

HTML

<div ng-repeat="Image in Images">
  <img ngsrc='{{Image}}'/>
</div>

Angularjs

app.controller('myCtrl',function($scope){
    $scope.Images=[];
       for(var i =1 ;i<=5; i++){ 
       $scope.Images[i] = "../CSS/down-icn.png"; 
    }
});