* @ngdoc provider * @name $locationProvider * @this * * @description * Use the `$locationProvider` to configure how the application deep linking paths are stored.
()
| 13747 | * Use the `$locationProvider` to configure how the application deep linking paths are stored. |
| 13748 | */ |
| 13749 | function $LocationProvider() { |
| 13750 | var hashPrefix = '', |
| 13751 | html5Mode = { |
| 13752 | enabled: false, |
| 13753 | requireBase: true, |
| 13754 | rewriteLinks: true |
| 13755 | }; |
| 13756 | |
| 13757 | /** |
| 13758 | * @ngdoc method |
| 13759 | * @name $locationProvider#hashPrefix |
| 13760 | * @description |
| 13761 | * The default value for the prefix is `''`. |
| 13762 | * @param {string=} prefix Prefix for hash part (containing path and search) |
| 13763 | * @returns {*} current value if used as getter or itself (chaining) if used as setter |
| 13764 | */ |
| 13765 | this.hashPrefix = function(prefix) { |
| 13766 | if (isDefined(prefix)) { |
| 13767 | hashPrefix = prefix; |
| 13768 | return this; |
| 13769 | } else { |
| 13770 | return hashPrefix; |
| 13771 | } |
| 13772 | }; |
| 13773 | |
| 13774 | /** |
| 13775 | * @ngdoc method |
| 13776 | * @name $locationProvider#html5Mode |
| 13777 | * @description |
| 13778 | * @param {(boolean|Object)=} mode If boolean, sets `html5Mode.enabled` to value. |
| 13779 | * If object, sets `enabled`, `requireBase` and `rewriteLinks` to respective values. Supported |
| 13780 | * properties: |
| 13781 | * - **enabled** – `{boolean}` – (default: false) If true, will rely on `history.pushState` to |
| 13782 | * change urls where supported. Will fall back to hash-prefixed paths in browsers that do not |
| 13783 | * support `pushState`. |
| 13784 | * - **requireBase** - `{boolean}` - (default: `true`) When html5Mode is enabled, specifies |
| 13785 | * whether or not a <base> tag is required to be present. If `enabled` and `requireBase` are |
| 13786 | * true, and a base tag is not present, an error will be thrown when `$location` is injected. |
| 13787 | * See the {@link guide/$location $location guide for more information} |
| 13788 | * - **rewriteLinks** - `{boolean|string}` - (default: `true`) When html5Mode is enabled, |
| 13789 | * enables/disables URL rewriting for relative links. If set to a string, URL rewriting will |
| 13790 | * only happen on links with an attribute that matches the given string. For example, if set |
| 13791 | * to `'internal-link'`, then the URL will only be rewritten for `<a internal-link>` links. |
| 13792 | * Note that [attribute name normalization](guide/directive#normalization) does not apply |
| 13793 | * here, so `'internalLink'` will **not** match `'internal-link'`. |
| 13794 | * |
| 13795 | * @returns {Object} html5Mode object if used as getter or itself (chaining) if used as setter |
| 13796 | */ |
| 13797 | this.html5Mode = function(mode) { |
| 13798 | if (isBoolean(mode)) { |
| 13799 | html5Mode.enabled = mode; |
| 13800 | return this; |
| 13801 | } else if (isObject(mode)) { |
| 13802 | |
| 13803 | if (isBoolean(mode.enabled)) { |
| 13804 | html5Mode.enabled = mode.enabled; |
| 13805 | } |
| 13806 |
nothing calls this directly
no test coverage detected