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,14 @@ function $RouteProvider() {
141
141
* Adds a new route definition to the `$route` service.
142
142
*/
143
143
this . when = function ( path , route ) {
144
+ //copy original route object to preserve params inherited from proto chain
145
+ var routeCopy = angular . copy ( route ) ;
146
+ if ( angular . isUndefined ( routeCopy . reloadOnSearch ) ) {
147
+ routeCopy . reloadOnSearch = true ;
148
+ }
144
149
routes [ path ] = angular . extend (
145
- { reloadOnSearch : true } ,
146
- route ,
147
- path && pathRegExp ( path , route )
150
+ routeCopy ,
151
+ path && pathRegExp ( path , routeCopy )
148
152
) ;
149
153
150
154
// create redirection for trailing slashes
@@ -155,7 +159,7 @@ function $RouteProvider() {
155
159
156
160
routes [ redirectPath ] = angular . extend (
157
161
{ redirectTo : path } ,
158
- pathRegExp ( redirectPath , route )
162
+ pathRegExp ( redirectPath , routeCopy )
159
163
) ;
160
164
}
161
165
Original file line number Diff line number Diff line change @@ -294,6 +294,21 @@ describe('$route', function() {
294
294
$rootScope . $digest ( ) ;
295
295
expect ( $route . current ) . toBeDefined ( ) ;
296
296
} ) ) ;
297
+
298
+ it ( "should use route params inherited from prototype chain" , function ( ) {
299
+ function BaseRoute ( ) { }
300
+ BaseRoute . prototype . templateUrl = 'foo.html' ;
301
+
302
+ module ( function ( $routeProvider ) {
303
+ $routeProvider . when ( '/foo' , new BaseRoute ) ;
304
+ } ) ;
305
+
306
+ inject ( function ( $route , $location , $rootScope ) {
307
+ $location . path ( '/foo' ) ;
308
+ $rootScope . $digest ( ) ;
309
+ expect ( $route . current . templateUrl ) . toBe ( 'foo.html' ) ;
310
+ } ) ;
311
+ } ) ;
297
312
} ) ;
298
313
299
314
You can’t perform that action at this time.
0 commit comments