@@ -183,11 +183,20 @@ function $RouteProvider() {
183
183
* `redirectTo` takes precedence over `resolveRedirectTo`, so specifying both on the same
184
184
* route definition, will cause the latter to be ignored.
185
185
*
186
+ * - `[reloadOnUrl=true]` - `{boolean=}` - reload route when any part of the URL changes
187
+ * (inluding the path) even if the new URL maps to the same route.
188
+ *
189
+ * If the option is set to `false` and the URL in the browser changes, but the new URL maps
190
+ * to the same route, then a `$routeUpdate` event is broadcasted on the root scope (without
191
+ * reloading the route).
192
+ *
186
193
* - `[reloadOnSearch=true]` - `{boolean=}` - reload route when only `$location.search()`
187
194
* or `$location.hash()` changes.
188
195
*
189
- * If the option is set to `false` and url in the browser changes, then
190
- * `$routeUpdate` event is broadcasted on the root scope.
196
+ * If the option is set to `false` and the URL in the browser changes, then a `$routeUpdate`
197
+ * event is broadcasted on the root scope (without reloading the route).
198
+ *
199
+ * **Note:** This option has no effect if `reloadOnUrl` is set to false.
191
200
*
192
201
* - `[caseInsensitiveMatch=false]` - `{boolean=}` - match routes without being case sensitive
193
202
*
@@ -202,6 +211,9 @@ function $RouteProvider() {
202
211
this . when = function ( path , route ) {
203
212
//copy original route object to preserve params inherited from proto chain
204
213
var routeCopy = shallowCopy ( route ) ;
214
+ if ( angular . isUndefined ( routeCopy . reloadOnUrl ) ) {
215
+ routeCopy . reloadOnUrl = true ;
216
+ }
205
217
if ( angular . isUndefined ( routeCopy . reloadOnSearch ) ) {
206
218
routeCopy . reloadOnSearch = true ;
207
219
}
@@ -544,8 +556,9 @@ function $RouteProvider() {
544
556
* @name $route#$routeUpdate
545
557
* @eventType broadcast on root scope
546
558
* @description
547
- * The `reloadOnSearch` property has been set to false, and we are reusing the same
548
- * instance of the Controller.
559
+ * Any of the `reloadOnSearch` and `reloadOnUrl` properties has been set to false and we are
560
+ * reusing the same instance of the route (including template, controller instance, resolved
561
+ * dependencies etc).
549
562
*
550
563
* @param {Object } angularEvent Synthetic event object
551
564
* @param {Route } current Current/previous route information.
@@ -653,9 +666,21 @@ function $RouteProvider() {
653
666
var lastRoute = $route . current ;
654
667
655
668
preparedRoute = parseRoute ( ) ;
656
- preparedRouteIsUpdateOnly = preparedRoute && lastRoute && preparedRoute . $$route === lastRoute . $$route
657
- && angular . equals ( preparedRoute . pathParams , lastRoute . pathParams )
658
- && ! preparedRoute . reloadOnSearch && ! forceReload ;
669
+ preparedRouteIsUpdateOnly =
670
+ // IF this is not a forced reload
671
+ ! forceReload
672
+ // AND both `lastRoute`/`preparedRoute` are defined
673
+ && preparedRoute && lastRoute
674
+ // AND they map to the same Route Definition Object
675
+ && ( preparedRoute . $$route === lastRoute . $$route )
676
+ // AND `reloadOnUrl` is disabled
677
+ && ( ! preparedRoute . reloadOnUrl
678
+ // OR `reloadOnSearch` is disabled
679
+ || ( ! preparedRoute . reloadOnSearch
680
+ // AND both routes have the same path params
681
+ && angular . equals ( preparedRoute . pathParams , lastRoute . pathParams )
682
+ )
683
+ ) ;
659
684
660
685
if ( ! preparedRouteIsUpdateOnly && ( lastRoute || preparedRoute ) ) {
661
686
if ( $rootScope . $broadcast ( '$routeChangeStart' , preparedRoute , lastRoute ) . defaultPrevented ) {
0 commit comments