Closed sashless closed 8 years ago
First, there are some problems with your setup:
1) in main.tab1
state you are using named views. The controller
and controllerAs
properties belong to the VIEW, not the state.
2) in main.tab1
state you put the resolve on the view. The resolve
property belongs to the STATE not the view.
It looks like you want to activate both states when the app starts.
However, it takes 500ms to activate tab1 Then, the second transition (to tab2) starts, and SUPERSEDES the original transition (to tab1). A superseded transition is cancelled (this is normal UI-Router stuff).
You should activate tab1, wait for the transition to complete, and THEN activate tab2.
.run(function($timeout, $state, $rootScope) {
$rootScope.$state = $state;
function goto(state) {
return function() { return $state.go(state); }
}
$timeout(goto('main.tab1'), 200)
.then(goto('main.tab2'));
I am using
In my plunkr, checkout
app.js
line 29. When you use100
ms for the$timeout
inside theresolve
function tab1 will be loaded properly and tab2 afterwards.When you use instead
500
ms only tab2 will be loaded. Tab1 will be never displayed unless you hit the linktab1
The
$timeout
is just a placeholder for anypromise
. In my real world case that is a$http
request were the response time differs.http://plnkr.co/edit/lQ7acurykufGYnX28FrI?p=preview