0

I want to make default my dashboard page.So write following code in app.js $urlRouterProvider.otherwise('/app/dashboard')

But when ionic application launch in mobil device,login page before show,dashboard page is appearing afterward disappearing.I want to dashboard page never be show before from login page How can i solve this problem.

Login Page:

<ion-view view-title="Kayıt Ol" hide-back-button="true"> <ion-content class="padding "> <div style="padding:40px 0 40px 0; text-align:center;font-size:45px;color:#ff6707"> Login </div> <div class="card list-inset"> <form novalidate > <label class="item item-input"> <input type="email" placeholder="Email" required ng-model="user.email"> </label> <label class="item item-input"> <input type="password" placeholder="Email" required ng-model="user.password"> </label> </form> </div> <button class="button button-block button-positive icon-button icon-center ion-person-add" ng-disabled="!user.email && !user.password" ng-click="Login()">Login</button> </ion-content> </ion-view> 

app.js

 .state('app', { url: "/app", cache: false, abstract: true, templateUrl: "templates/app.html", controller: 'AppCtrl' }) .state('login', { url: "/login", cache: false, abstract: true, templateUrl: "templates/login.html", controller: 'LoginCtrl' }) .state('app.dashboard', { url: '/dashboard', cache: false, views: { 'menuContent': { templateUrl: 'templates/dashboard.html', controller: 'DashboardCtrl' } } }) $urlRouterProvider.otherwise('/app/dashboard'); 
5
  • its hard to understand..!'login page before show,dashboard page is appearing afterward disappearing' explain properly..!do u want : not to show dashboard if user is not login..!? and also update ques with complete state declarations..! Commented Mar 9, 2016 at 17:48
  • if user is not login, dashborad is not already show.But while ionic app is launching,dashboard is appearing and a few seconds after dissapearing.After that login page is showing. Commented Mar 9, 2016 at 18:31
  • have u used $state.go('app.login'); in controller..!is login a state..?or Modal..?can u update your question with some of your code..! Commented Mar 9, 2016 at 18:36
  • Login page html and app .js code is sharing.I hope helps you to understand better. Commented Mar 9, 2016 at 18:50
  • Yasemin, can you please post your controllers? Commented Mar 10, 2016 at 2:43

1 Answer 1

0

Why don't use $urlRouterProvider.otherwise('/login')? then in LoginCtrl controller, you should check if the user is logged and then you can use $state.go('app.dashboard').

But, maybe this is not the best idea. I am not sure about this but here you have a good answer with another method: https://stackoverflow.com/a/32734632/2012904

And i think you are wrong with the use of the abstract property. Check this: https://stackoverflow.com/a/24969722/2012904

But like others said, post your code in controllers so we can understand your issue at all.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.