title: Create dynamic scope variables in AngularJs inside loop
body: <p>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:</p>
  
  <pre><code>$scope.lists=[{listName:'list1'},{listName:'list2'}];
  
  for(var i=0;i&lt;$scope.lists.length;i++){
    var listName = $scope.lists[i].listName;
    listName = $parse(listName);
    listName.assign($scope,[]);
    $scope.$apply();
  }
  </code></pre>
  
  <p>The above code throws an error saying: <code>$digest</code> already in progress. </p>
  
  <p>The code works ok when used without looping just for one as done in:
  <a href="https://stackoverflow.com/questions/18875486/setting-dynamic-scope-variables-in-angularjs-scope-some-string">Setting dynamic scope variables in AngularJs - scope.&lt;some_string&gt;</a></p>
  
  <p>I ultimately am looking for <code>$scope.list1=[]</code> and <code>$scope.list2=[]</code> as 2 separate arrays. </p>
  
  <p>Any leads would be awesome. Thanks.</p>