how to make sure that data assigned to a variable before going through the controller?

21 Views Asked by At

The code fails because it is waiting for view model which has quite a big size data (that's why I put $onInit but it seems not working). Once I debug it and after a certain period of time, the code runs smoothly, which means before assigning values to the variable, it's going through to check the length of the array. How can I make sure that data loaded first before everything else?

this.$onInit = function () {
    $scope.viewModel = viewModel; 
};

$scope.trueOrFalse= Array($scope.viewModel.length).fill(false);
0

There are 0 best solutions below