* @ngdoc provider * @name $locationProvider * @this * * @description * Use the `$locationProvider` to configure how the application deep linking paths are stored.
()
| 15163 | * Use the `$locationProvider` to configure how the application deep linking paths are stored. |
| 15164 | */ |
| 15165 | function $LocationProvider() { |
| 15166 | var hashPrefix = '!', |
| 15167 | html5Mode = { |
| 15168 | enabled: false, |
| 15169 | requireBase: true, |
| 15170 | rewriteLinks: true |
| 15171 | }; |
| 15172 | |
| 15173 | /** |
| 15174 | * @ngdoc method |
| 15175 | * @name $locationProvider#hashPrefix |
| 15176 | * @description |
| 15177 | * The default value for the prefix is `'!'`. |
| 15178 | * @param {string=} prefix Prefix for hash part (containing path and search) |
| 15179 | * @returns {*} current value if used as getter or itself (chaining) if used as setter |
| 15180 | */ |
| 15181 | this.hashPrefix = function(prefix) { |
| 15182 | if (isDefined(prefix)) { |
| 15183 | hashPrefix = prefix; |
| 15184 | return this; |
| 15185 | } else { |
| 15186 | return hashPrefix; |
| 15187 | } |
| 15188 | }; |
| 15189 | |
| 15190 | /** |
| 15191 | * @ngdoc method |
| 15192 | * @name $locationProvider#html5Mode |
| 15193 | * @description |
| 15194 | * @param {(boolean|Object)=} mode If boolean, sets `html5Mode.enabled` to value. |
| 15195 | * If object, sets `enabled`, `requireBase` and `rewriteLinks` to respective values. Supported |
| 15196 | * properties: |
| 15197 | * - **enabled** – `{boolean}` – (default: false) If true, will rely on `history.pushState` to |
| 15198 | * change urls where supported. Will fall back to hash-prefixed paths in browsers that do not |
| 15199 | * support `pushState`. |
| 15200 | * - **requireBase** - `{boolean}` - (default: `true`) When html5Mode is enabled, specifies |
| 15201 | * whether or not a <base> tag is required to be present. If `enabled` and `requireBase` are |
| 15202 | * true, and a base tag is not present, an error will be thrown when `$location` is injected. |
| 15203 | * See the {@link guide/$location $location guide for more information} |
| 15204 | * - **rewriteLinks** - `{boolean|string}` - (default: `true`) When html5Mode is enabled, |
| 15205 | * enables/disables URL rewriting for relative links. If set to a string, URL rewriting will |
| 15206 | * only happen on links with an attribute that matches the given string. For example, if set |
| 15207 | * to `'internal-link'`, then the URL will only be rewritten for `<a internal-link>` links. |
| 15208 | * Note that [attribute name normalization](guide/directive#normalization) does not apply |
| 15209 | * here, so `'internalLink'` will **not** match `'internal-link'`. |
| 15210 | * |
| 15211 | * @returns {Object} html5Mode object if used as getter or itself (chaining) if used as setter |
| 15212 | */ |
| 15213 | this.html5Mode = function(mode) { |
| 15214 | if (isBoolean(mode)) { |
| 15215 | html5Mode.enabled = mode; |
| 15216 | return this; |
| 15217 | } else if (isObject(mode)) { |
| 15218 | |
| 15219 | if (isBoolean(mode.enabled)) { |
| 15220 | html5Mode.enabled = mode.enabled; |
| 15221 | } |
| 15222 |
nothing calls this directly
no test coverage detected