Resolve dependencies


Hi all

I’m just starting out with ionic. I’m building an app that retrieve data from geonames as well as from forecastio. The data received from goenames will be stored in a sqlite database (county names). These names must be available before the view is rendered to the user.

To do that I’m using a config module with resolve, I think this is working. But I would like to cater for the following startup sequence.

get all country data, if it does not exist create the database and table, get the data from geomanes and insert the data into the table, get the data from the table and call the controller with the data.

So not every function needs to be resolved but if one fails then other functions needs to be performed based on the outcome of the previous function.

I have tried the following:

getAllCountries: function() {
InitService.getCountries().then(function(rest) {
}, function(reason) {

But that did not seem to work.

But I don’t know if one can structure the code this way, and if so how?

Appreciate the help.