@@ -147,7 +147,6 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $
147
147
if ( ! queue [ parentName ] ) {
148
148
queue [ parentName ] = [ ] ;
149
149
}
150
-
151
150
queue [ parentName ] . push ( state ) ;
152
151
}
153
152
@@ -164,8 +163,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $
164
163
if ( states . hasOwnProperty ( name ) ) throw new Error ( "State '" + name + "'' is already defined" ) ;
165
164
166
165
// Get parent name
167
- var parentName =
168
- ( name . indexOf ( '.' ) !== - 1 ) ? name . substring ( 0 , name . lastIndexOf ( '.' ) )
166
+ var parentName = ( name . indexOf ( '.' ) !== - 1 ) ? name . substring ( 0 , name . lastIndexOf ( '.' ) )
169
167
: ( isString ( state . parent ) ) ? state . parent
170
168
: '' ;
171
169
@@ -265,14 +263,19 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $
265
263
transition : null
266
264
} ;
267
265
266
+ $state . reload = function reload ( ) {
267
+ $state . transitionTo ( $state . current , $stateParams , { reload : true , inherit : false , notify : false } ) ;
268
+ } ;
269
+
268
270
$state . go = function go ( to , params , options ) {
269
271
return this . transitionTo ( to , params , extend ( { inherit : true , relative : $state . $current } , options ) ) ;
270
272
} ;
271
273
272
274
$state . transitionTo = function transitionTo ( to , toParams , options ) {
273
- if ( ! isDefined ( options ) ) options = ( options === true || options === false ) ? { location : options } : { } ;
274
275
toParams = toParams || { } ;
275
- options = extend ( { location : true , inherit : false , relative : null , notify : true , $retry : false } , options ) ;
276
+ options = extend ( {
277
+ location : true , inherit : false , relative : null , notify : true , reload : false , $retry : false
278
+ } , options || { } ) ;
276
279
277
280
var from = $state . $current , fromParams = $state . params , fromPath = from . path ;
278
281
var evt , toState = findState ( to , options . relative ) ;
@@ -297,8 +300,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $
297
300
if ( retryTransition !== $state . transition ) return TransitionSuperseded ;
298
301
redirect . options . $retry = true ;
299
302
return $state . transitionTo ( redirect . to , redirect . toParams , redirect . options ) ;
300
- } ,
301
- function ( ) {
303
+ } , function ( ) {
302
304
return TransitionAborted ;
303
305
} ) ;
304
306
syncUrl ( ) ;
@@ -325,7 +327,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $
325
327
// Starting from the root of the path, keep all levels that haven't changed
326
328
var keep , state , locals = root . locals , toLocals = [ ] ;
327
329
for ( keep = 0 , state = toPath [ keep ] ;
328
- state && state === fromPath [ keep ] && equalForKeys ( toParams , fromParams , state . ownParams ) ;
330
+ state && state === fromPath [ keep ] && equalForKeys ( toParams , fromParams , state . ownParams ) && ! options . reload ;
329
331
keep ++ , state = toPath [ keep ] ) {
330
332
locals = toLocals [ keep ] = state . locals ;
331
333
}
@@ -334,7 +336,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $
334
336
// But clear 'transition', as we still want to cancel any other pending transitions.
335
337
// TODO: We may not want to bump 'transition' if we're called from a location change that we've initiated ourselves,
336
338
// because we might accidentally abort a legitimate transition initiated from code?
337
- if ( to === from && locals === from . locals ) {
339
+ if ( to === from && locals === from . locals && ! options . reload ) {
338
340
syncUrl ( ) ;
339
341
$state . transition = null ;
340
342
return $q . when ( $state . current ) ;
0 commit comments