0

im trying to call a simple function in angularjs, but when im calling the function from the controller, the app crash. for example, if i call the function from ng-click event, everything is working fine.

the code is about json object array that i want to push his data to another array

the code:

$scope.imgindex=[];


$scope.makeindex = function()
{
  for(var i=0;i<$scope.zimmers.length;i++)
  {
    $scope.imgindex.push({id:$scope.zimmers[i]['ZimmerID'],index:0});
  }
}


makeindex();

1 Answers1

0

We need to know the object $scope.zimmers to give you a clear answer, but apparently your code has an error when you trying to access the $scope.zimmers[i]['ZimmerID'] variable, maybe you are trying access before it is available.