This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +23
-4
lines changed
2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -141,10 +141,13 @@ function $RouteProvider(){
141
141
* Adds a new route definition to the `$route` service.
142
142
*/
143
143
this . when = function ( path , route ) {
144
+ var routeCopy = angular . copy ( route ) ;
145
+ if ( angular . isUndefined ( routeCopy . reloadOnSearch ) ) {
146
+ routeCopy . reloadOnSearch = true ;
147
+ }
144
148
routes [ path ] = angular . extend (
145
- { reloadOnSearch : true } ,
146
- route ,
147
- path && pathRegExp ( path , route )
149
+ routeCopy ,
150
+ path && pathRegExp ( path , routeCopy )
148
151
) ;
149
152
150
153
// create redirection for trailing slashes
@@ -155,7 +158,7 @@ function $RouteProvider(){
155
158
156
159
routes [ redirectPath ] = angular . extend (
157
160
{ redirectTo : path } ,
158
- pathRegExp ( redirectPath , route )
161
+ pathRegExp ( redirectPath , routeCopy )
159
162
) ;
160
163
}
161
164
Original file line number Diff line number Diff line change @@ -294,6 +294,22 @@ describe('$route', function() {
294
294
$rootScope . $digest ( ) ;
295
295
expect ( $route . current ) . toBeDefined ( ) ;
296
296
} ) ) ;
297
+
298
+ it ( "should redirect when route params are inherited prototypically" , function ( ) {
299
+ module ( function ( $routeProvider ) {
300
+ var BaseRoute = function BaseRoute ( ) {
301
+ BaseRoute . prototype . templateUrl = 'foo.html' ;
302
+ } ;
303
+ var route = new BaseRoute ( ) ;
304
+ $routeProvider . when ( '/foo' , route ) ;
305
+ } ) ;
306
+
307
+ inject ( function ( $route , $location , $rootScope ) {
308
+ $location . path ( '/foo' ) ;
309
+ $rootScope . $digest ( ) ;
310
+ expect ( $route . current . templateUrl ) . toBe ( 'foo.html' ) ;
311
+ } ) ;
312
+ } ) ;
297
313
} ) ;
298
314
299
315
You can’t perform that action at this time.
0 commit comments