mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-27 06:54:01 +00:00
Small refactor in $location service
Added new inner method updateLastLocation()
This commit is contained in:
parent
99f25050a3
commit
2d61040fb0
1 changed files with 11 additions and 6 deletions
|
|
@ -23,8 +23,7 @@ angularServiceInject("$location", function(browser) {
|
||||||
browser.addPollFn(function() {
|
browser.addPollFn(function() {
|
||||||
if (lastBrowserUrl != browser.getUrl()) {
|
if (lastBrowserUrl != browser.getUrl()) {
|
||||||
update(lastBrowserUrl = browser.getUrl());
|
update(lastBrowserUrl = browser.getUrl());
|
||||||
lastLocationHref = location.href;
|
updateLastLocation();
|
||||||
lastLocationHash = location.hash;
|
|
||||||
scope.$eval();
|
scope.$eval();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -33,8 +32,7 @@ angularServiceInject("$location", function(browser) {
|
||||||
this.$onEval(PRIORITY_LAST, updateBrowser);
|
this.$onEval(PRIORITY_LAST, updateBrowser);
|
||||||
|
|
||||||
update(lastBrowserUrl);
|
update(lastBrowserUrl);
|
||||||
lastLocationHref = location.href;
|
updateLastLocation();
|
||||||
lastLocationHash = location.hash;
|
|
||||||
|
|
||||||
return location;
|
return location;
|
||||||
|
|
||||||
|
|
@ -134,6 +132,14 @@ angularServiceInject("$location", function(browser) {
|
||||||
update(location.href);
|
update(location.href);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update information about last location
|
||||||
|
*/
|
||||||
|
function updateLastLocation() {
|
||||||
|
lastLocationHref = location.href;
|
||||||
|
lastLocationHash = location.hash;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If location has changed, update the browser
|
* If location has changed, update the browser
|
||||||
* This method is called at the end of $eval() phase
|
* This method is called at the end of $eval() phase
|
||||||
|
|
@ -143,8 +149,7 @@ angularServiceInject("$location", function(browser) {
|
||||||
|
|
||||||
if (location.href != lastLocationHref) {
|
if (location.href != lastLocationHref) {
|
||||||
browser.setUrl(lastBrowserUrl = location.href);
|
browser.setUrl(lastBrowserUrl = location.href);
|
||||||
lastLocationHref = location.href;
|
updateLastLocation();
|
||||||
lastLocationHash = location.hash;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue