diff options
| author | Vojta Jina | 2010-10-31 02:14:55 +0200 | 
|---|---|---|
| committer | Igor Minar | 2010-10-31 21:37:54 -0700 | 
| commit | 2d61040fb085f5d3a226d39726e105c1e6bd7006 (patch) | |
| tree | fe40b9cc0535253639ce3789683a268c461800bf /src/services.js | |
| parent | 99f25050a34a0f0e2b0bdc63a55f38097f7098db (diff) | |
| download | angular.js-2d61040fb085f5d3a226d39726e105c1e6bd7006.tar.bz2 | |
Small refactor in $location service
Added new inner method updateLastLocation()
Diffstat (limited to 'src/services.js')
| -rw-r--r-- | src/services.js | 17 | 
1 files changed, 11 insertions, 6 deletions
diff --git a/src/services.js b/src/services.js index fca4bca1..9af69403 100644 --- a/src/services.js +++ b/src/services.js @@ -23,8 +23,7 @@ angularServiceInject("$location", function(browser) {    browser.addPollFn(function() {      if (lastBrowserUrl != browser.getUrl()) {        update(lastBrowserUrl = browser.getUrl()); -      lastLocationHref = location.href; -      lastLocationHash = location.hash; +      updateLastLocation();        scope.$eval();      }    }); @@ -33,8 +32,7 @@ angularServiceInject("$location", function(browser) {    this.$onEval(PRIORITY_LAST, updateBrowser);    update(lastBrowserUrl); -  lastLocationHref = location.href; -  lastLocationHash = location.hash; +  updateLastLocation();    return location; @@ -135,6 +133,14 @@ angularServiceInject("$location", function(browser) {    }    /** +   * Update information about last location +   */ +  function updateLastLocation() { +    lastLocationHref = location.href; +    lastLocationHash = location.hash; +  } + +  /**     * If location has changed, update the browser     * This method is called at the end of $eval() phase     */ @@ -143,8 +149,7 @@ angularServiceInject("$location", function(browser) {      if (location.href != lastLocationHref) {    	        browser.setUrl(lastBrowserUrl = location.href); -      lastLocationHref = location.href; -      lastLocationHash = location.hash; +      updateLastLocation();      }    }  | 
