Here is my situation. For simplicity, let's assume I have a system called a BookListManager that manages lists of library books.
app.service('BookListManager', function(){
var BookListManager = {
activeBookList:null,
addNewBookList:function(){
//create new BookList()
//set new BookList to activeBookList;
}
}
}
I then have a factory that creates a BookList object.
app.factory('BookList', function(){
var BookList = function(params){
//RESTful request via resource to fetch booklist data.
//Assign booklist data to this object.
//Create Book object for each book in this book list.
}
return BookList;
});
And now I have a Book object that belongs within each book list.
app.factory('Book', function(){
var Book = function(){
//RESTful resource call for book data.
//Assign book data to Book object.
}
return Book;
});
How can I create a promise chain to wait until after both the BookList and Books have finished collecting their data from the AJAX requests before assigning it as the activeBookList inside my BookListManager service?
I am using the latest version of Angular. Thanks.