I am new to Angular.js and am trying to create dynamic scope variables in AngularJs inside a for Loop. This is something as below:
$scope.lists=[{listName:'list1'},{listName:'list2'}];
for(var i=0;i<$scope.lists.length;i++){
var listName = $scope.lists[i].listName;
listName = $parse(listName);
listName.assign($scope,[]);
$scope.$apply();
}
The above code throws an error saying: $digest
already in progress.
The code works ok when used without looping just for one as done in: Setting dynamic scope variables in AngularJs - scope.<some_string>
I ultimately am looking for $scope.list1=[]
and $scope.list2=[]
as 2 separate arrays.
Any leads would be awesome. Thanks.