* @ngdoc provider * @name $locationProvider * @description * Use the `$locationProvider` to configure how the application deep linking paths are stored.
()
| 11264 | * Use the `$locationProvider` to configure how the application deep linking paths are stored. |
| 11265 | */ |
| 11266 | function $LocationProvider() { |
| 11267 | var hashPrefix = '', |
| 11268 | html5Mode = { |
| 11269 | enabled: false, |
| 11270 | requireBase: true, |
| 11271 | rewriteLinks: true |
| 11272 | }; |
| 11273 | |
| 11274 | /** |
| 11275 | * @ngdoc method |
| 11276 | * @name $locationProvider#hashPrefix |
| 11277 | * @description |
| 11278 | * @param {string=} prefix Prefix for hash part (containing path and search) |
| 11279 | * @returns {*} current value if used as getter or itself (chaining) if used as setter |
| 11280 | */ |
| 11281 | this.hashPrefix = function(prefix) { |
| 11282 | if (isDefined(prefix)) { |
| 11283 | hashPrefix = prefix; |
| 11284 | return this; |
| 11285 | } else { |
| 11286 | return hashPrefix; |
| 11287 | } |
| 11288 | }; |
| 11289 | |
| 11290 | /** |
| 11291 | * @ngdoc method |
| 11292 | * @name $locationProvider#html5Mode |
| 11293 | * @description |
| 11294 | * @param {(boolean|Object)=} mode If boolean, sets `html5Mode.enabled` to value. |
| 11295 | * If object, sets `enabled`, `requireBase` and `rewriteLinks` to respective values. Supported |
| 11296 | * properties: |
| 11297 | * - **enabled** – `{boolean}` – (default: false) If true, will rely on `history.pushState` to |
| 11298 | * change urls where supported. Will fall back to hash-prefixed paths in browsers that do not |
| 11299 | * support `pushState`. |
| 11300 | * - **requireBase** - `{boolean}` - (default: `true`) When html5Mode is enabled, specifies |
| 11301 | * whether or not a <base> tag is required to be present. If `enabled` and `requireBase` are |
| 11302 | * true, and a base tag is not present, an error will be thrown when `$location` is injected. |
| 11303 | * See the {@link guide/$location $location guide for more information} |
| 11304 | * - **rewriteLinks** - `{boolean}` - (default: `true`) When html5Mode is enabled, |
| 11305 | * enables/disables url rewriting for relative links. |
| 11306 | * |
| 11307 | * @returns {Object} html5Mode object if used as getter or itself (chaining) if used as setter |
| 11308 | */ |
| 11309 | this.html5Mode = function(mode) { |
| 11310 | if (isBoolean(mode)) { |
| 11311 | html5Mode.enabled = mode; |
| 11312 | return this; |
| 11313 | } else if (isObject(mode)) { |
| 11314 | |
| 11315 | if (isBoolean(mode.enabled)) { |
| 11316 | html5Mode.enabled = mode.enabled; |
| 11317 | } |
| 11318 | |
| 11319 | if (isBoolean(mode.requireBase)) { |
| 11320 | html5Mode.requireBase = mode.requireBase; |
| 11321 | } |
| 11322 | |
| 11323 | if (isBoolean(mode.rewriteLinks)) { |
nothing calls this directly
no test coverage detected