问题
The AngularDart ng-repeat
directive seems to require unique values; e.g., the following
<li ng-repeat="x in ['Alice', 'Bob', 'Alice']">...</li>
results in
[NgErr50] ngRepeat error! Duplicates in a repeater are not allowed.
Use 'track by' expression to specify unique keys.
Assuming that the list of strings is obtained from some external source and that uniqueness of values is not guaranteed, how can the [NgErr50]
be avoided?
回答1:
This works:
<li ng-repeat="x in ['Alice', 'Bob', 'Alice'] track by $index">...</li>
For more options, see the ng-repeat API docs.
来源:https://stackoverflow.com/questions/21763136/how-to-use-angulardart-ng-repeat-over-a-list-of-simple-values-possibly-with-dupl