AngularJS:未捕获错误:[$ rootScope:infdig]:ng-repeat不在数组上工作

时间:2018-04-03 08:16:07

标签: javascript angularjs angularjs-directive angularjs-ng-repeat

ng-repeat没有在数组上工作,我收到以下错误: 错误:[$ rootScope:infdig]

<tr>
 <td ng-repeat="(v,version) in versions">
                 <table>
                    <tr>
                       <td ng-hide="true">
                            {{getUniqueOS(AppVersions[version])  }}                                
                        </td> 
                         // ng-repeat is not working on my array : 
                        <td ng-repeat="os in osList track by $index">
                           {{os}}    
                        </td>                     
                    </tr>

                 </table>        
            </td>
</tr>

以下是我的控制器:

   $scope.osList = [];
  $scope.getUniqueOS = function (objVersion) 
  {
        var OsVersions =[];
       OsVersions = objVersion.abc.os;
       for (var curOSVersion in  OsVersions ) 
       { 
        $scope.osList.push(curOSVersion);
       }
      console.log($scope.osList);
   }

并且数据被推送到我的数组,如下所示:

(33) ["Windows 7 Ent 64 Bits SP1", "Mac", "Windows 10", "Windows 7 Ent 64 Bits SP1", "Mac", "Windows 10", "Windows 7 Ent 64 Bits SP1", "Mac", "Windows 10", "Windows 7 Ent 64 Bits SP1", "Mac", "Windows 10", "Windows 7 Ent 64 Bits SP1", "Mac", "Windows 10", "Windows 7 Ent 64 Bits SP1", "Mac", "Windows 10", "Windows 7 Ent 64 Bits SP1", "Mac", "Windows 10", "Windows 7 Ent 64 Bits SP1", "Mac", "Windows 10", "Windows 7 Ent 64 Bits SP1", "Mac", "Windows 10", "Windows 7 Ent 64 Bits SP1", "Mac", "Windows 10", "Windows 7 Ent 64 Bits SP1", "Mac", "Windows 10"]

实际上阵列应该只有3个元素:Windows 7,Mac和Windows 10.但它会像上面那样重复多次。

0 个答案:

没有答案