Currently, I am managing 3 arrays and wish to toggle between them using ng-repeat:
$scope.fooDataObj = {
array1:[{name:'john', id:'1'},{name:'jerry', id:'2'}],
array2[{name:'bill', id:'1'},{name:'tom', id:'2'}],
array3:[]
}
Here is my ng-repeat code:
<li ng-repeat="data in fooDataObj track by data.id"></li>
My goal is to dynamically switch between the arrays of data within my object in the most efficient way possible.
Essentially, when a user clicks <button></button>
, it should switch from utilizing array1
in the ng-repeat
to array2
.
I have achieved this by setting ng-repeat="data in fooData"
and then triggering
$scope.fooData = fooDataObj.array1
on click. However, this method lacks performance, especially when switching between populated arrays and an empty array.