In the trivial example below, I have a method call (getMoreProducts) that needs to be called after the first method call (getProducts) has completed.
As I am new to angularjs (and fairly new to JS), I would like to confirm if there is another way of achieving this. My concern is that if another method needs to be called after getMoreProducts, the code will then be three levels deep, and so on.
.controller('ProductController',function(ProductService, $scope){
$scope.products = [];
$scope.moreProducts = [];
ProductService.getProducts().then(function(res){
$scope.products = res.data;
ProductService.getMoreProducts().then(function(res){
$scope.moreProducts = res.data;
});
});
For this example, assume the ProductService methods are simply calling invoking a HTTP GET call.