* @ngdoc provider * @name $locationProvider * @this * * @description * Use the `$locationProvider` to configure how the application deep linking paths are stored.
()
| 14326 | * Use the `$locationProvider` to configure how the application deep linking paths are stored. |
| 14327 | */ |
| 14328 | function $LocationProvider() { |
| 14329 | var hashPrefix = '!', |
| 14330 | html5Mode = { |
| 14331 | enabled: false, |
| 14332 | requireBase: true, |
| 14333 | rewriteLinks: true |
| 14334 | }; |
| 14335 | |
| 14336 | /** |
| 14337 | * @ngdoc method |
| 14338 | * @name $locationProvider#hashPrefix |
| 14339 | * @description |
| 14340 | * The default value for the prefix is `'!'`. |
| 14341 | * @param {string=} prefix Prefix for hash part (containing path and search) |
| 14342 | * @returns {*} current value if used as getter or itself (chaining) if used as setter |
| 14343 | */ |
| 14344 | this.hashPrefix = function(prefix) { |
| 14345 | if (isDefined(prefix)) { |
| 14346 | hashPrefix = prefix; |
| 14347 | return this; |
| 14348 | } else { |
| 14349 | return hashPrefix; |
| 14350 | } |
| 14351 | }; |
| 14352 | |
| 14353 | /** |
| 14354 | * @ngdoc method |
| 14355 | * @name $locationProvider#html5Mode |
| 14356 | * @description |
| 14357 | * @param {(boolean|Object)=} mode If boolean, sets `html5Mode.enabled` to value. |
| 14358 | * If object, sets `enabled`, `requireBase` and `rewriteLinks` to respective values. Supported |
| 14359 | * properties: |
| 14360 | * - **enabled** – `{boolean}` – (default: false) If true, will rely on `history.pushState` to |
| 14361 | * change urls where supported. Will fall back to hash-prefixed paths in browsers that do not |
| 14362 | * support `pushState`. |
| 14363 | * - **requireBase** - `{boolean}` - (default: `true`) When html5Mode is enabled, specifies |
| 14364 | * whether or not a <base> tag is required to be present. If `enabled` and `requireBase` are |
| 14365 | * true, and a base tag is not present, an error will be thrown when `$location` is injected. |
| 14366 | * See the {@link guide/$location $location guide for more information} |
| 14367 | * - **rewriteLinks** - `{boolean|string}` - (default: `true`) When html5Mode is enabled, |
| 14368 | * enables/disables URL rewriting for relative links. If set to a string, URL rewriting will |
| 14369 | * only happen on links with an attribute that matches the given string. For example, if set |
| 14370 | * to `'internal-link'`, then the URL will only be rewritten for `<a internal-link>` links. |
| 14371 | * Note that [attribute name normalization](guide/directive#normalization) does not apply |
| 14372 | * here, so `'internalLink'` will **not** match `'internal-link'`. |
| 14373 | * |
| 14374 | * @returns {Object} html5Mode object if used as getter or itself (chaining) if used as setter |
| 14375 | */ |
| 14376 | this.html5Mode = function(mode) { |
| 14377 | if (isBoolean(mode)) { |
| 14378 | html5Mode.enabled = mode; |
| 14379 | return this; |
| 14380 | } else if (isObject(mode)) { |
| 14381 | |
| 14382 | if (isBoolean(mode.enabled)) { |
| 14383 | html5Mode.enabled = mode.enabled; |
| 14384 | } |
| 14385 |
nothing calls this directly
no test coverage detected