@@ -130,6 +130,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
130
130
// .state(name, state)
131
131
this . state = state ;
132
132
function state ( name , definition ) {
133
+ /*jshint validthis: true */
133
134
if ( isObject ( name ) ) definition = name ;
134
135
else definition . name = name ;
135
136
registerState ( definition ) ;
@@ -141,6 +142,9 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
141
142
$get . $inject = [ '$rootScope' , '$q' , '$templateFactory' , '$injector' , '$stateParams' , '$location' , '$urlRouter' ] ;
142
143
function $get ( $rootScope , $q , $templateFactory , $injector , $stateParams , $location , $urlRouter ) {
143
144
145
+ var TransitionSuperseded = $q . reject ( new Error ( 'transition superseded' ) ) ;
146
+ var TransitionPrevented = $q . reject ( new Error ( 'transition prevented' ) ) ;
147
+
144
148
$state = {
145
149
params : { } ,
146
150
current : root . self ,
@@ -157,14 +161,13 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
157
161
}
158
162
} ;
159
163
160
- var TransitionSuperseded = $q . reject ( new Error ( 'transition superseded' ) ) ;
161
- var TransitionPrevented = $q . reject ( new Error ( 'transition prevented' ) ) ;
162
-
163
164
function transitionTo ( to , toParams , updateLocation ) {
164
165
if ( ! isDefined ( updateLocation ) ) updateLocation = true ;
165
166
166
- to = findState ( to ) ; if ( to . abstract ) throw new Error ( "Cannot transition to abstract state '" + to + "'" ) ;
167
- var toPath = to . path , from = $state . $current , fromParams = $state . params , fromPath = from . path ;
167
+ to = findState ( to ) ;
168
+ if ( to . abstract ) throw new Error ( "Cannot transition to abstract state '" + to + "'" ) ;
169
+ var toPath = to . path ,
170
+ from = $state . $current , fromParams = $state . params , fromPath = from . path ;
168
171
169
172
// Starting from the root of the path, keep all levels that haven't changed
170
173
var keep , state , locals = root . locals , toLocals = [ ] ;
@@ -183,7 +186,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
183
186
return $q . when ( $state . current ) ;
184
187
}
185
188
186
- // Normalize parameters before we pass them to event handlers etc.
189
+ // Normalize/filter parameters before we pass them to event handlers etc.
187
190
var normalizedToParams = { } ;
188
191
forEach ( to . params , function ( name ) {
189
192
var value = toParams [ name ] ;
@@ -227,7 +230,6 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
227
230
}
228
231
229
232
// Enter 'to' states not kept
230
- // TODO: Should we be invoking onEnter in a separate pass after we've updated $state and $location?
231
233
for ( l = keep ; l < toPath . length ; l ++ ) {
232
234
entering = toPath [ l ] ;
233
235
entering . locals = toLocals [ l ] ;
@@ -239,7 +241,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
239
241
// Update globals in $state
240
242
$state . $current = to ;
241
243
$state . current = to . self ;
242
- $state . params = toParams
244
+ $state . params = toParams ;
243
245
copy ( $state . params , $stateParams ) ;
244
246
$state . transition = null ;
245
247
@@ -287,7 +289,9 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
287
289
function resolve ( deps , dst ) {
288
290
forEach ( deps , function ( value , key ) {
289
291
promises . push ( $q
290
- . when ( isString ( value ) ? $injector . get ( value ) : $injector . invoke ( value , state . self , locals ) )
292
+ . when ( isString ( value ) ?
293
+ $injector . get ( value ) :
294
+ $injector . invoke ( value , state . self , locals ) )
291
295
. then ( function ( result ) {
292
296
dst [ key ] = result ;
293
297
} ) ) ;
0 commit comments