I have implemented AngularJS
in a nodewebkit application.
There are three main views:
- Home.html
- Conversation.html
- Login.html
Upon login, the following code is executed:
$state.go('home.main');
which triggers the following state configuration:
$stateProvider.state('home.main', {
url: '/home',
views: {
"mainContent": {
templateUrl: 'views/home.html',
controller: 'loginController'
}
}
}
In the home.html, there is a server call made through socket.io to fetch all conversations. During this loading time, if the user clicks on Logout, they are redirected back to the login page.
$scope.logout = function(){
//Logout Logic
$state.go('login');
}
This results in another routing action as shown below:
$stateProvider.state('login', {
url: '/login',
templateUrl: 'views/login.html',
controller: "loginController"
});
When a user tries to log back in, the server response may redirect them to /home/conv.html.
The challenge here is to prevent all server calls when transitioning from /home to /login without disabling the logout button during data retrieval. Is there a way to achieve this seamlessly in the routing process?