Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Escaped "short" word and added ability to stop updatingRoute in beforeUpdateRoute #577

Closed
wants to merge 6 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/service/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ angularServiceInject('$route', function($location, $routeParams) {
rootScope = this,
dirty = 0,
forceReload = false,
stopUpdate = false,
$route = {
routes: routes,

Expand Down Expand Up @@ -250,6 +251,14 @@ angularServiceInject('$route', function($location, $routeParams) {
return match ? dst : null;
}

function stopUpdateCallback() {
stopUpdate = true;
}

function refreshUpdateState() {
stopUpdate = false;
}

function updateRoute() {
var next = parseRoute(),
last = $route.current,
Expand All @@ -262,7 +271,11 @@ angularServiceInject('$route', function($location, $routeParams) {
last.scope && last.scope.$emit('$routeUpdate');
} else {
forceReload = false;
rootScope.$broadcast('$beforeRouteChange', next, last);
rootScope.$broadcast('$beforeRouteChange', next, last, stopUpdateCallback);
if(stopUpdate) {
refreshUpdateState();
return;
}
last && last.scope && last.scope.$destroy();
$route.current = next;
if (next) {
Expand Down