diff --git a/src/ng/location.js b/src/ng/location.js index cf50952d53c3..6a2dacec4f1e 100644 --- a/src/ng/location.js +++ b/src/ng/location.js @@ -222,6 +222,12 @@ LocationUrl.prototype = { * @private */ $$replace: false, + + /** + * TODO + * @private + */ + $$preventLocationChangedEvent: false, /** * @ngdoc method @@ -394,6 +400,16 @@ LocationUrl.prototype = { replace: function() { this.$$replace = true; return this; + }, + /** + * TODO + * + * @description + * If called, only browser URL will be updated without reinitialize, for example, controllers + */ + preventLocationChangedEvent: function() { + this.$$preventLocationChangedEvent = true; + return this; } }; @@ -600,7 +616,11 @@ function $LocationProvider(){ } else { $browser.url($location.absUrl(), $location.$$replace); $location.$$replace = false; - afterLocationChange(oldUrl); + if (!$location.$$preventLocationChangedEvent) { + afterLocationChange(oldUrl); + } else { + $location.$$preventLocationChangedEvent = false; + } } }); } @@ -611,6 +631,7 @@ function $LocationProvider(){ return $location; function afterLocationChange(oldUrl) { + if (!$$onlyChangeUrl $rootScope.$broadcast('$locationChangeSuccess', $location.absUrl(), oldUrl); } }];