Reputation: 11153
I'm using ionic to create a mobile app. I'm new to ionic/angularjs so this is a huge learning curve...
When I open my app in browser by using a fresh ionic serve
command, the default page is my login page as I would expect based on the $urlRouteProvider.otherwise
command. When I use cordova emulate android
the default app is my cards page which I don't understand why... What's going on and how do I set the default state to be my login page? (PS I say I used a 'fresh' ionic serve command meaning it wasn't already open in a browser and simply refreshing the last page.)
Here is the relevant sections of my app.js
angular.module('starter', ['ionic', 'starter.controllers'])
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('app', {
url: "/app",
abstract: true,
templateUrl: "templates/menu.html",
controller: 'CardsCtrl'
})
.state('app.cards', {
url: "/cards",
views: {
'menuContent' :{
templateUrl: "templates/cards.html",
controller: 'CardsCtrl'
}
}
})
.state('app.login',{
url:'/login',
views:{
'menuContent':{
templateUrl:'templates/login.html',
controller: 'LoginCtrl'
}
}
});
$urlRouterProvider.otherwise('/app/login');
})
My CardsCtrl
is just an array so that I can use ng-repeat
, there is no logic that would route it to login page. My LoginCtrl
is currently an empty controller.
Based on this information why is this routing the default page
Upvotes: 0
Views: 229
Reputation: 2692
Every information you have provided is just fine. Since it is working fine in your web browser, you should look at options of debugging your app on device.
Most trivial way is to look at logcat. It will display all error messages that occured at runtime in your terminal. Using logcat is very easy. This is one of the resources: http://wildermuth.com/2013/4/30/Debugging_PhoneGap_with_the_Android_Console
Upvotes: 1