aboutsummaryrefslogtreecommitdiffstats
path: root/src/service/location.js
diff options
context:
space:
mode:
authorMisko Hevery2011-11-08 20:42:16 -0800
committerMisko Hevery2011-11-14 20:31:15 -0800
commitc283bf6035566aa8ff3178676a133de6878b5d1b (patch)
tree7840abc149b6b056a76ac5016756fed32e6364ab /src/service/location.js
parentb3c17f3fdcf37403c5fb71f9916983a10e17c783 (diff)
downloadangular.js-c283bf6035566aa8ff3178676a133de6878b5d1b.tar.bz2
refactor($location): merged $locationConfig service into $locationProvider
Diffstat (limited to 'src/service/location.js')
-rw-r--r--src/service/location.js38
1 files changed, 24 insertions, 14 deletions
diff --git a/src/service/location.js b/src/service/location.js
index 7cc5c273..11a69e96 100644
--- a/src/service/location.js
+++ b/src/service/location.js
@@ -420,15 +420,35 @@ function locationGetterSetter(property, preprocess) {
* For more information see {@link guide/dev_guide.services.$location Developer Guide: Angular Services: Using $location}
*/
function $LocationProvider(){
- this.$get = ['$rootScope', '$browser', '$sniffer', '$locationConfig', '$document',
- function( $rootScope, $browser, $sniffer, $locationConfig, $document) {
+ var hashPrefix = '',
+ html5Mode = false;
+
+ this.hashPrefix = function(prefix) {
+ if (isDefined(prefix)) {
+ hashPrefix = prefix;
+ return this;
+ } else {
+ return html5Mode;
+ }
+ }
+
+ this.html5Mode = function(mode) {
+ if (isDefined(mode)) {
+ html5Mode = mode;
+ return this;
+ } else {
+ return html5Mode;
+ }
+ };
+
+ this.$get = ['$rootScope', '$browser', '$sniffer', '$document',
+ function( $rootScope, $browser, $sniffer, $document) {
var currentUrl,
basePath = $browser.baseHref() || '/',
pathPrefix = pathPrefixFromBase(basePath),
- hashPrefix = $locationConfig.hashPrefix || '',
initUrl = $browser.url();
- if ($locationConfig.html5Mode) {
+ if (html5Mode) {
if ($sniffer.history) {
currentUrl = new LocationUrl(convertToHtml5Url(initUrl, basePath, hashPrefix), pathPrefix);
} else {
@@ -505,13 +525,3 @@ function $LocationProvider(){
return currentUrl;
}];
}
-
-//TODO(misko): refactor to service
-function $LocationConfigProvider(){
- this.$get = function() {
- return {
- html5Mode: false,
- hashPrefix: ''
- };
- };
-}