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