MCPcopy
hub / github.com/angular-ui/ui-router / $LocationProvider

Function $LocationProvider

test/angular/1.6/angular.js:14495–14795  ·  view source on GitHub ↗

* @ngdoc provider * @name $locationProvider * @this * * @description * Use the `$locationProvider` to configure how the application deep linking paths are stored.

()

Source from the content-addressed store, hash-verified

14493 * Use the `$locationProvider` to configure how the application deep linking paths are stored.
14494 */
14495function $LocationProvider() {
14496 var hashPrefix = '!',
14497 html5Mode = {
14498 enabled: false,
14499 requireBase: true,
14500 rewriteLinks: true
14501 };
14502
14503 /**
14504 * @ngdoc method
14505 * @name $locationProvider#hashPrefix
14506 * @description
14507 * The default value for the prefix is `'!'`.
14508 * @param {string=} prefix Prefix for hash part (containing path and search)
14509 * @returns {*} current value if used as getter or itself (chaining) if used as setter
14510 */
14511 this.hashPrefix = function(prefix) {
14512 if (isDefined(prefix)) {
14513 hashPrefix = prefix;
14514 return this;
14515 } else {
14516 return hashPrefix;
14517 }
14518 };
14519
14520 /**
14521 * @ngdoc method
14522 * @name $locationProvider#html5Mode
14523 * @description
14524 * @param {(boolean|Object)=} mode If boolean, sets `html5Mode.enabled` to value.
14525 * If object, sets `enabled`, `requireBase` and `rewriteLinks` to respective values. Supported
14526 * properties:
14527 * - **enabled** – `{boolean}` – (default: false) If true, will rely on `history.pushState` to
14528 * change urls where supported. Will fall back to hash-prefixed paths in browsers that do not
14529 * support `pushState`.
14530 * - **requireBase** - `{boolean}` - (default: `true`) When html5Mode is enabled, specifies
14531 * whether or not a <base> tag is required to be present. If `enabled` and `requireBase` are
14532 * true, and a base tag is not present, an error will be thrown when `$location` is injected.
14533 * See the {@link guide/$location $location guide for more information}
14534 * - **rewriteLinks** - `{boolean|string}` - (default: `true`) When html5Mode is enabled,
14535 * enables/disables URL rewriting for relative links. If set to a string, URL rewriting will
14536 * only happen on links with an attribute that matches the given string. For example, if set
14537 * to `'internal-link'`, then the URL will only be rewritten for `<a internal-link>` links.
14538 * Note that [attribute name normalization](guide/directive#normalization) does not apply
14539 * here, so `'internalLink'` will **not** match `'internal-link'`.
14540 *
14541 * @returns {Object} html5Mode object if used as getter or itself (chaining) if used as setter
14542 */
14543 this.html5Mode = function(mode) {
14544 if (isBoolean(mode)) {
14545 html5Mode.enabled = mode;
14546 return this;
14547 } else if (isObject(mode)) {
14548
14549 if (isBoolean(mode.enabled)) {
14550 html5Mode.enabled = mode.enabled;
14551 }
14552

Callers

nothing calls this directly

Calls 15

baseHrefMethod · 0.80
urlMethod · 0.80
stateMethod · 0.80
isDefinedFunction · 0.70
isBooleanFunction · 0.70
isObjectFunction · 0.70
isStringFunction · 0.70
serverBaseFunction · 0.70
stripHashFunction · 0.70
stripFileFunction · 0.70
nodeName_Function · 0.70
isUndefinedFunction · 0.70

Tested by

no test coverage detected