From 16086aa37c5c0c98f5c4a42d2a15136bb6d18605 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Tue, 4 Jan 2011 17:54:37 -0800 Subject: $location service should utilize onhashchange events instead of polling --- src/services.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/services.js') diff --git a/src/services.js b/src/services.js index 0b983ffb..91bd226d 100644 --- a/src/services.js +++ b/src/services.js @@ -68,19 +68,17 @@ angularServiceInject("$document", function(window){
$location = {{$location}}
*/
-angularServiceInject("$location", function(browser) {
+angularServiceInject("$location", function($browser) {
var scope = this,
location = {toString:toString, update:update, updateHash: updateHash},
- lastBrowserUrl = browser.getUrl(),
+ lastBrowserUrl = $browser.getUrl(),
lastLocationHref,
lastLocationHash;
- browser.addPollFn(function() {
- if (lastBrowserUrl != browser.getUrl()) {
- update(lastBrowserUrl = browser.getUrl());
- updateLastLocation();
- scope.$eval();
- }
+ $browser.onHashChange(function() {
+ update(lastBrowserUrl = $browser.getUrl());
+ updateLastLocation();
+ scope.$eval();
});
this.$onEval(PRIORITY_FIRST, updateBrowser);
@@ -219,7 +217,7 @@ angularServiceInject("$location", function(browser) {
updateLocation();
if (location.href != lastLocationHref) {
- browser.setUrl(lastBrowserUrl = location.href);
+ $browser.setUrl(lastBrowserUrl = location.href);
updateLastLocation();
}
}
--
cgit v1.2.3