New Ionic programmer problem with router and state.go


#1

Hi I have a simple router login,register and dashboard see below, i am able from login to go in register and dashboard but when i try to go from register to dashboard i have a strange behaviour. The link change http://10.171.23.204:8100/#/dashboard and I see that I enter in dashboard function thought a console.log and so $state.go(“dashboard”); is execeuted and i see after the state.go of register controller that the console.log of the dashboard controller is executed. THE PROBLEM: But the dashborad template from register to dashborard is not loaded…I don’t understand why

$stateProvider
.state(‘login’, {
cache: false,
url: ‘/login’,
views: {
‘login’: {
templateUrl: ‘templates/login.html’,
controller: ‘LoginCtrl’
}
}
});
$stateProvider
.state(‘register’, {
cache: false,
url: ‘/register’,
views: {
‘register’: {
templateUrl: ‘templates/register.html’,
controller: ‘Register’
}
}
});
$stateProvider
.state(‘dashboard’, {
cache: false,
url: ‘/dashboard’,
views: {
‘dashboard’: {
templateUrl: ‘templates/dashboard.html’,
controller: ‘Dashboard’
}
}
});


#2

could you write it like this

$stateProvider
.state('login', {
cache: false,
url: '/login',
views: {
'login': {
templateUrl: 'templates/login.html',
controller: 'LoginCtrl'
}
}
})
.state('register', {
cache: false,
url: '/register',
views: {
'register': {
templateUrl: 'templates/register.html',
controller: 'Register'
}
}
})
.state('dashboard', {
cache: false,
url: '/dashboard',
views: {
'dashboard': {
templateUrl: 'templates/dashboard.html',
controller: 'Dashboard'
}
}
});