diff options
| author | Misko Hevery | 2010-04-05 11:46:53 -0700 | 
|---|---|---|
| committer | Misko Hevery | 2010-04-05 11:46:53 -0700 | 
| commit | 7a4b48020688060debe9cb0f9c17615d7585cbe7 (patch) | |
| tree | 48a5b1d8cf92bb272028a106ab9ea3ec16f477a2 /src/services.js | |
| parent | 4bfa4e230d5ebdd582068effe7f4f1b60c43093a (diff) | |
| download | angular.js-7a4b48020688060debe9cb0f9c17615d7585cbe7.tar.bz2 | |
added ng:switch widget
Diffstat (limited to 'src/services.js')
| -rw-r--r-- | src/services.js | 29 | 
1 files changed, 10 insertions, 19 deletions
diff --git a/src/services.js b/src/services.js index 16b48031..2532d3d3 100644 --- a/src/services.js +++ b/src/services.js @@ -6,8 +6,8 @@ angularService("$document", function(window){  var URL_MATCH = /^(file|ftp|http|https):\/\/(\w+:{0,1}\w*@)?([\w\.]*)(:([0-9]+))?([^\?#]+)(\?([^#]*))?((#([^\?]*))?(\?([^\?]*))?)$/;  var DEFAULT_PORTS = {'http': 80, 'https': 443, 'ftp':21};  angularService("$location", function(browser){ -  var scope = this; -  function location(url){ +  var scope = this, location = {parse:parse, toString:toString}; +  function parse(url){      if (isDefined(url)) {        var match = URL_MATCH.exec(url);        if (match) { @@ -23,17 +23,19 @@ angularService("$location", function(browser){          location.hashSearch = parseKeyValue(match[13]);        }      } -    var hashKeyValue = toKeyValue(location.hashSearch); -    var hash = (location.hashPath ? location.hashPath : '') + -      (hashKeyValue ? '?' + hashKeyValue : ''); +  } +  function toString() { +    var hashKeyValue = toKeyValue(location.hashSearch), +        hash = (location.hashPath ? location.hashPath : '') + (hashKeyValue ? '?' + hashKeyValue : '');      return location.href.split('#')[0] + '#' + (hash ? hash : '');    }    browser.watchUrl(function(url){ -    location(url); +    parse(url); +    scope.$root.$eval();    }); -  location(browser.getUrl()); +  parse(browser.getUrl());    this.$onEval(PRIORITY_LAST, function(){ -    var href = location(); +    var href = toString();      if (href != location.href) {        browser.setUrl(href);        location.href = href; @@ -42,14 +44,3 @@ angularService("$location", function(browser){    return location;  }, {inject: ['$browser']}); -if (!angularService['$browser']) { -  var browserSingleton; -  angularService('$browser', function browserFactory(){ -    if (!browserSingleton) { -      browserSingleton = new Browser(window.location); -      browserSingleton.startUrlWatcher(); -    } -    return browserSingleton; -  }); -} -  | 
