This is my code in controller
myFactory.getPoints().success(function (data) {
$scope.points = data;
});
myFactory.getStates().success(function (data) {
$scope.states = data;
});
myFactory.getLeases().success(function (data) {
$scope.leases = data;
});
I am expecting $scope.leases gets the value after $scope.points and $scope.states gets their values. I learned that $q with .then is not synchronous. Is that right?
Answer: I have derived below from the answers
$q.all([
myFactory.getPoints().success(function (data) {
$scope.Points = data;
}).error(function (data) {
$scope.error = "An Error has occurred while loading Points! " + data.ExceptionMessage;
}), //more, more, more
]).then(function () {
myFactory.getLease().success(function (data) {
$scope.leases = data;
}).error(function (data) {
$scope.error = "An Error has occurred while loading Leases! " + data.ExceptionMessage;
})
});