My controller fetch data from two external JSON files, filter it and then should render on the view. But whole operation take some time (approximately 30 mil sec) and view is loaded first. So data cannot be found by HTML code.
How can I delay loading of my view in order to load data from controller first? Or maybe there is another solution?
$scope.ratePlansRelated = [];
$http.get('rooms.json').then(function(res){
$scope.rooms = res.data;
});
$http.get('ratePlans.json').then(function(res){
$scope.ratePlans = res.data;
});
// delay calling that function in order to load data from json first
setTimeout(assignRatePlans,25);
function assignRatePlans()
{
//filter data and assing it to $scope.ratePlansRelated here
}
$scope.dataHasLoaded = falseto initialize hiding your view and then when the async operation has finished set totruein conjunction withng-if