diff options
| author | Igor Minar | 2011-01-04 17:54:37 -0800 |
|---|---|---|
| committer | Igor Minar | 2011-01-07 14:39:41 -0800 |
| commit | 16086aa37c5c0c98f5c4a42d2a15136bb6d18605 (patch) | |
| tree | 8b8e4b6b585e9d267588cb324745a3246bc5bc41 /src/services.js | |
| parent | c0a26b18531482d493d544cf1a207586e8aacaf4 (diff) | |
| download | angular.js-16086aa37c5c0c98f5c4a42d2a15136bb6d18605.tar.bz2 | |
$location service should utilize onhashchange events instead of polling
Diffstat (limited to 'src/services.js')
| -rw-r--r-- | src/services.js | 16 |
1 files changed, 7 insertions, 9 deletions
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){ <input type='text' name="$location.hash"/> <pre>$location = {{$location}}</pre> */ -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(); } } |
