I created an ionicLoading
with a function called startNow()
to navigate from original-page
to my-next-page
.
The first time, I simply invoke startNow()
which takes me directly to my-next-page
after the $timeout()
service is triggered.
However, I encountered a problem:
In my
myLoadingTemplate.html
, there is a cancel button that also triggers thestartNow(true)
function. The issue arises when I click this cancel button during loading - the page redirects back to theoriginal-page
. Nevertheless, after 2500ms, the page then correctly navigates tomy-next-page
.
How can I resolve this issue?
$scope.startNow = function(is_force)
{
if(is_force===true)
{
$state.go('orignal-page');
$ionicLoading.hide();
}else
{
$ionicLoading.show({
templateUrl: "myLoadingTemplate.html",
nBackdrop: false
}).then(function(){
$timeout(function(){
$state.go('my-next-page');
$ionicLoading.hide();
},2500);
});
}
}