diff --git a/src/state.js b/src/state.js index 555f1895c..117e3952b 100644 --- a/src/state.js +++ b/src/state.js @@ -194,7 +194,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) { if (!state[abstractKey] && state.url) { $urlRouterProvider.when(state.url, ['$match', '$stateParams', function ($match, $stateParams) { if ($state.$current.navigable != state || !equalForKeys($match, $stateParams)) { - $state.transitionTo(state, $match, { location: false }); + $state.transitionTo(state, $match, { inherit: true, location: false }); } }]); } @@ -1075,7 +1075,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) { if (options.location && to.navigable) { $urlRouter.push(to.navigable.url, to.navigable.locals.globals.$stateParams, { - replace: options.location === 'replace' + $$avoidResync: true, replace: options.location === 'replace' }); } diff --git a/src/urlRouter.js b/src/urlRouter.js index 4e5fbc4a2..b60dbd206 100644 --- a/src/urlRouter.js +++ b/src/urlRouter.js @@ -265,7 +265,7 @@ function $UrlRouterProvider( $locationProvider, $urlMatcherFactory) { $get.$inject = ['$location', '$rootScope', '$injector', '$browser']; function $get( $location, $rootScope, $injector, $browser) { - var baseHref = $browser.baseHref(), location = $location.url(); + var baseHref = $browser.baseHref(), location = $location.url(), lastPushedUrl = undefined; function appendBasePath(url, isHtml5, absolute) { if (baseHref === '/') return url; @@ -277,6 +277,9 @@ function $UrlRouterProvider( $locationProvider, $urlMatcherFactory) { // TODO: Optimize groups of rules with non-empty prefix into some sort of decision tree function update(evt) { if (evt && evt.defaultPrevented) return; + if (lastPushedUrl && $location.url() === lastPushedUrl) + return lastPushedUrl = undefined; + lastPushedUrl = undefined; function check(rule) { var handled = rule($injector, $location); @@ -349,6 +352,7 @@ function $UrlRouterProvider( $locationProvider, $urlMatcherFactory) { push: function(urlMatcher, params, options) { $location.url(urlMatcher.format(params || {})); + lastPushedUrl = options && options.$$avoidResync ? $location.url() : undefined; if (options && options.replace) $location.replace(); },