* @ngdoc provider * @name $locationProvider * @this * * @description * Use the `$locationProvider` to configure how the application deep linking paths are stored.
()
| 15098 | * Use the `$locationProvider` to configure how the application deep linking paths are stored. |
| 15099 | */ |
| 15100 | function $LocationProvider() { |
| 15101 | var hashPrefix = '!', |
| 15102 | html5Mode = { |
| 15103 | enabled: false, |
| 15104 | requireBase: true, |
| 15105 | rewriteLinks: true |
| 15106 | }; |
| 15107 | |
| 15108 | /** |
| 15109 | * @ngdoc method |
| 15110 | * @name $locationProvider#hashPrefix |
| 15111 | * @description |
| 15112 | * The default value for the prefix is `'!'`. |
| 15113 | * @param {string=} prefix Prefix for hash part (containing path and search) |
| 15114 | * @returns {*} current value if used as getter or itself (chaining) if used as setter |
| 15115 | */ |
| 15116 | this.hashPrefix = function(prefix) { |
| 15117 | if (isDefined(prefix)) { |
| 15118 | hashPrefix = prefix; |
| 15119 | return this; |
| 15120 | } else { |
| 15121 | return hashPrefix; |
| 15122 | } |
| 15123 | }; |
| 15124 | |
| 15125 | /** |
| 15126 | * @ngdoc method |
| 15127 | * @name $locationProvider#html5Mode |
| 15128 | * @description |
| 15129 | * @param {(boolean|Object)=} mode If boolean, sets `html5Mode.enabled` to value. |
| 15130 | * If object, sets `enabled`, `requireBase` and `rewriteLinks` to respective values. Supported |
| 15131 | * properties: |
| 15132 | * - **enabled** – `{boolean}` – (default: false) If true, will rely on `history.pushState` to |
| 15133 | * change urls where supported. Will fall back to hash-prefixed paths in browsers that do not |
| 15134 | * support `pushState`. |
| 15135 | * - **requireBase** - `{boolean}` - (default: `true`) When html5Mode is enabled, specifies |
| 15136 | * whether or not a <base> tag is required to be present. If `enabled` and `requireBase` are |
| 15137 | * true, and a base tag is not present, an error will be thrown when `$location` is injected. |
| 15138 | * See the {@link guide/$location $location guide for more information} |
| 15139 | * - **rewriteLinks** - `{boolean|string}` - (default: `true`) When html5Mode is enabled, |
| 15140 | * enables/disables URL rewriting for relative links. If set to a string, URL rewriting will |
| 15141 | * only happen on links with an attribute that matches the given string. For example, if set |
| 15142 | * to `'internal-link'`, then the URL will only be rewritten for `<a internal-link>` links. |
| 15143 | * Note that [attribute name normalization](guide/directive#normalization) does not apply |
| 15144 | * here, so `'internalLink'` will **not** match `'internal-link'`. |
| 15145 | * |
| 15146 | * @returns {Object} html5Mode object if used as getter or itself (chaining) if used as setter |
| 15147 | */ |
| 15148 | this.html5Mode = function(mode) { |
| 15149 | if (isBoolean(mode)) { |
| 15150 | html5Mode.enabled = mode; |
| 15151 | return this; |
| 15152 | } else if (isObject(mode)) { |
| 15153 | |
| 15154 | if (isBoolean(mode.enabled)) { |
| 15155 | html5Mode.enabled = mode.enabled; |
| 15156 | } |
| 15157 |
nothing calls this directly
no test coverage detected