AngularJS: ng-repeat duplicate error

I came across a problem in Angular today with using ng-repeat directive.
For example if you have a list of numbers you want to iterate through and in that list you may have duplicate numbers, well ng-repeat will throw an error complaining about the duplicate value.

Here is an example code snippet of my html code with the problem:

<li ng-repeat="number in [1,2,3,4,1]">{{number}}</>

This is what I had to do to fix the problem:

<li ng-repeat="number in [1,2,3,4,1] track by $index">{{number}}</>

By telling ng-repeat to track each item by index each of the numbers in the list will be displayed.