Help with navigation

Hi,

I am new to ionic. I want to implement the following -

  1. If the user has not logged in, display login page on the start of the app.
  2. The login page has a link to sign up, on click on this link, display sign up page.
  3. Once the user has logged in, i want to display the dashboard which contains the side menu.

I have the pages designed, but I having navigation. It just doesnt work. Any ideas or suggestions to implement this ? Or any link to sample project where i can refer to ?


.config(function($urlRouterProvider) {
if (!localStorage.getItem(‘customer_unic’)) {
$urlRouterProvider.otherwise(’/app/login’);
} else {
$urlRouterProvider.otherwise(’/app/main’);
}
})

set “customer_unic” after login

yeah but the problem is, that you can login / logout in an app without reloading… so the config is not executed again… read about angularjs providers.

Solution here:

  • use ui.Routers reolves in states ;). There can you execute logic before a state is called --> there you can check if you are logged in or not and possible redirect.

Another solution is a global $stateChangeStart listener to achieve the same ;).

Thank you for your help. I tried the following -

My index.html file looks like this -
image

My login.html template looks like this which is located in templates folder in www -
image

I have created a seperate js file for routing and included in index.html after initial inclusion of all the previous mandatory js. The route.js file looks like this -

image

I want to load the login page by default since i have not implemented the login functionality. But all i get is a blank white screen. Any idea what am i doing wrong ?

In addition to the previous reply, my app.js file looks like this -