With a regular array in my controller:
$scope.results = ["file1","file2","file3","file4"];
Doing console.log($scope.results) outputs:
["file1","file2","file3","file4"]
My HTML:
<ul>
<li ng-repeat="result in results" type="item-text-wrap">
<div><img ng-src="{{result}}"/></div>
</li>
</ul>
Throws the error:
Error: [ngRepeat:dupes] Duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys.
If I add track by $index
<ul>
<li ng-repeat="result in results track by $index" type="item-text-wrap">
<div><img ng-src="{{result}}"/></div>
</li>
</ul>
Each character is treated as an item…
<div><img ng-src="%22"/></div>
<div><img ng-src="f"/></div>
<div><img ng-src="i"/></div>
<div><img ng-src="l"/></div>
<div><img ng-src="e"/></div>
<div><img ng-src="1"/></div>
<div><img ng-src="%22"/></div>
etc...
What am I doing wrong?
Thanks!