I have a controller (MyCtrl). The first thing that is to be done is to make a http.get call and get the response and assign it to $scope.input. The rest of the controller depends on $scope.input. But the problem is the code in the controller tries to access $scope.input before the http call is finished.
How can I solve this?
app.controller('MyCtrl', function($scope, $http, $routeParams, factory) {
factory.getInfo($routeParams.id)
.success(function(response) {
//The factory code make the http.get call
$scope.input = response;
});
//Rest of code accessing $scope.input before it is ready
});
P.S: I don't want to place the rest of controller code inside the success block
Thanks
$scope.input. So I'm afraid whether putting all that in one function would make sense in my caseui-routerhas aresolvefeature for these kind of scenarios.