Hey,
Ive been struggleling quite some time with an ionic app.
I have multiple controllers, multiple html pages.
Whenever I logoff ( I use the controller of the sidemenu ) I want to return to the first page.
Whenever I am on the first page I want to be able to login a diffrent user.
Whenever I enable cache:false in the UI-router of the target view ( menu.landingMenu )
it simply wont go to that page after the logout.
This is the code for the logout.
$scope.logOff = function () {
appData.clear();
$http.get(appData.hostURL + '/api/Account/logoff.aspx');
$scope.$destroy();
$localStorage.$reset();
CredentialService.del();
$state.go('login', { action: 'logoff' });
$timeout(function () {
$ionicHistory.clearCache();
$ionicHistory.clearHistory();
}, 1500)
}
This is the event int he loginController
// Check if a state change happened
$scope.$on('$stateChangeSuccess',
function onStateSuccess(event, toState, toParams, fromState) {
console.log(fromState);
console.log('This is the Fromstrate'), fromState;
console.log(toParams);
if (toState.name == "login") {
if (toParams.action == "logoff") {
// keep startup url (in case your app is an SPA with html5 url routing)
var initialHref = window.location.href;
function restartApplication() {
// Show splash screen (useful if your app takes time to load
// Reload original app url (ie your index.html file)
console.log("THis is a reload")
document.location.href = 'index.html';
}
restartApplication();
} else {
var storedCreds = CredentialService.get()
}
}
}
);
First of all, whenver I logout, and I press the submit button on the page of the login, it “refreshed” the page, it blincks shortly but does not react.
Whenever I click it a second time, it goes to the next page but wont reload the controller, thus rendering no data.
PLEASE can someone help me.