1
Good morning.
I have a question, I have a controller that searches some data of a webservice Rest, and persists them in the device database (Ionic), to perform the search of the data, I am using 'precedents'.
When you start the search I open a Loading screen, and I would like that after finishing all the Precedents executions, close the loading screen.
I’m doing it this way:
LoadingService.show();
var promise = function1.promise();
promise.then(function (result) {
if (result) {
MeuService.insert(result);
}
});
var promise2 = function2.promise();
promise2.then(function (result) {
if (result) {
MeuService.insert(result);
}
});
var promise3 = function3.promise();
promise3.then(function (result) {
if (result) {
MeuService.insert(result);
// Já tentei deixar aqui tbm..
// LoadingService.hide();
}
});
//??
LoadingService.hide();
The problem is that right after starting, it already closes the loading, and continues the execution of the predecessors. Where am I going wrong?