SoFunction
Updated on 2025-04-13

angular ng-repeat array instance

//Define an array first

anular code:

var app = ('serApp', []); 

('indexCtrl', function($scope, $http) 
{ $ = [{

<BR> n:'a'; 
        arr:['1','2','1'] 
      },{<BR><BR>  n:'b'; 
        arr:['4','5','6'] 
      }]; 
    }) 

html code:

<BR>
<div ng-controller="indexCtrl"><BR>      
<p>{{name}}</p><BR>      

<ul><BR>        
 <li ng-repeat="name in names">{{}}<BR>          
 <p ng-repeat="a in  track by $index" >{{a}}</p><BR>        
 </li><BR>      
</ul>
<BR>    
</div><BR><BR> 

track by $index  If there is a duplicate value, you need to add this code. Otherwise, the browser will report this error. Error: [ngRepeat:dupes] and will not render to the page.

The above example of arrays in the angular ng-repeat array is all the content I share with you. I hope you can give you a reference and I hope you can support me more.