@@ -113,7 +113,8 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
113
113
views : null ,
114
114
abstract : true
115
115
} ) ;
116
- root . locals = { } ;
116
+ root . locals = { globals : { $stateParams : { } } } ;
117
+ root . navigable = null ;
117
118
118
119
119
120
// .state(state)
@@ -135,8 +136,11 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
135
136
params : { } ,
136
137
current : root . self ,
137
138
$current : root ,
139
+
140
+ transition : null ,
138
141
$transition : $q . when ( root . self ) ,
139
142
143
+
140
144
transitionTo : transitionTo ,
141
145
142
146
is : function ( stateOrName ) {
@@ -181,15 +185,15 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
181
185
// (fully resolved) current locals, and pass this down the chain.
182
186
var resolved = $q . when ( locals ) ;
183
187
for ( var l = keep ; l < toPath . length ; l ++ , state = toPath [ l ] ) {
184
- locals = toLocals [ l ] = ( locals ? inherit ( locals ) : { } ) ;
188
+ locals = toLocals [ l ] = inherit ( locals ) ;
185
189
resolved = resolveState ( state , toParams , resolved , locals ) ;
186
190
}
187
191
188
192
// Once everything is resolved, we are ready to perform the actual transition
189
193
// and return a promise for the new state. We also keep track of what the
190
194
// current promise is, so that we can detect overlapping transitions and
191
195
// keep only the outcome of the last transition.
192
- var transition = $state . transition = resolved . then ( function ( ) {
196
+ var transition = $state . transition = $state . $transition = resolved . then ( function ( ) {
193
197
var l , entering , exiting ;
194
198
195
199
if ( $state . transition !== transition ) return ; // superseded by a new transition
@@ -218,6 +222,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
218
222
$state . current = to . self ;
219
223
$state . params = locals . globals . $stateParams ; // these are normalized, unlike toParams
220
224
copy ( $state . params , $stateParams ) ;
225
+ $state . transition = null ;
221
226
222
227
// Update $location
223
228
var toNav = to . navigable ;
@@ -226,9 +231,13 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
226
231
}
227
232
228
233
$rootScope . $broadcast ( '$stateChangeSuccess' , to . self , from . self ) ;
234
+
229
235
return $state . current ;
230
236
} , function ( error ) {
231
237
if ( $state . transition !== transition ) return ; // superseded by a new transition
238
+
239
+ $state . transition = null ;
240
+
232
241
$rootScope . $broadcast ( '$stateChangeError' , to . self , from . self , error ) ;
233
242
return $q . reject ( error ) ;
234
243
} ) ;
0 commit comments