Default in Ng-repeat every item should be guaranteed to be unique, otherwise console will play out the error to tell you which Key/value is repeated. Such as:
$scope. Items = [
' Red ',
' Blue ',
' Yellow ',
' White ',
' Blue '
];
This array, blue, repeats, so the HTML traverses it.
<li ng-repeat= "Item in Items" >{{Item}}</li>
The console throws an error:
Click the error link to angular website to see detailed errors, the official website is clearly given because the value is repeated:
Duplicates in a repeater are not allowed. Use "track by" expression to specify the unique keys. Repeater:item in items, Duplicate key:string:blue, Duplicate value:blue
This is confused, normal business in the array has a duplicate value is very normal, the array to be hard to make the only ng-repeat to traverse the white blind, continue to look down, found that the official website to a solution
<div ng-repeat= "value in [4, 4] track by $index" ></div>
So I changed it according to the plan.
<li ng-repeat= "item in items track by $index" >{{Item}}</li>
Refresh the page and the content is parsed correctly
In fact, Ng-repeat still need a unique key, but you do not track words by default is the item itself, but also only in ordinary data type strings, numbers and so will appear this problem, if replaced by object
$scope. Items = [
[' Red '],
[' Blue '],
[' Yellow '],
[' White '],
[' Blue ']
];
HTML revert to
<li ng-repeat= "Item in Items" >{{Item}}</li>
Execution results:
Do not understand the children's shoes then look at the following operational expressions, guess what the results are, and then in the browser console to try your answer is correct
[] === []