Is it possible to use ng-repeat
to iterate over an array with a string index? Review the sample code snippet below:
The following code is within a controller.
$scope.days = ["mon", "tue", "wed" .... "sun"];
$scope.arr = [];
$scope.arr["mon"] = ["apple","orange"];
$scope.arr["tue"] = ["blue","swish"];
.
.
.
$scope.arr["sun"] = ["pineapple","myfruit","carrot"];
Question - Is there a way to achieve something similar to the following using ng-repeat
?
<div ng-repeat="day in days">{{day}}
<span ng-repeat="item in arr(day)">{{item}}</span>
<-- Can we use "arr(day)" like this in Angular -->
</div>