Listen to what other said already. Once you are all ready to asynchronous,
you will come to something like this:

$http.get(...)
.then(function(response1) {
  return $http.get(...);
})
.then(function(response2) {
  return $http.get(...);
})
.then(function(response3) {
  return $http.get(...);
})
...you can chain like that as long as you want.
There is no need to return only $http promises. You can return whatever you
want, including other promises... or just regular values.

You can also attach error handlers just like with try...catch synchronous
equivalent.

Do your async/promises/Q/$q homework and you will discover brand new world
:-)

Regards,
Witold Szczerba
---
Sent from my mobile phone.
On Apr 25, 2014 5:12 PM, "Charlie Camus" <[email protected]> wrote:

> Hi all,
>
> I'm a beginner with Angular JS, and I think I missed something.
>
> Here is my code :
>
> $scope.listAccueil=function(){
>
>         $http.get('/findParams')
>             .success(function(data){
>                 $scope.params=data;
>             })
>
>         console.log($scope.params); // here $scope.params is empty even
> when '/findParams' bring something
>
>         $http.get('/listHabitats')
>             .success(function(data){
>                 $scope.listHabitats =[];
>                 for (var habitat in data) {
>                     if(habitat.prix>$scope.params.budget){
>                         habitat.color='list-group-item-danger';
>                         habitat.alert='Budget dépassé';
>                     }
>                     $scope.listHabitats.push(habitat);
>                 }
>             })
>     }
>
> So my problem is, I use $scope.params in the second http call and at that
> time it is empty. I don't understand why ! listAccueil is in a controller,
> and the $scope variable is global to all the controller isn't it ?
>
> Thank you
>
> --
> You received this message because you are subscribed to the Google Groups
> "AngularJS" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/angular.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to