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

Function $LocationProvider

test/angular/1.4/angular.js:12368–12656  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

12366 * Use the `$locationProvider` to configure how the application deep linking paths are stored.
12367 */
12368function $LocationProvider() {
12369 var hashPrefix = '',
12370 html5Mode = {
12371 enabled: false,
12372 requireBase: true,
12373 rewriteLinks: true
12374 };
12375
12376 /**
12377 * @ngdoc method
12378 * @name $locationProvider#hashPrefix
12379 * @description
12380 * @param {string=} prefix Prefix for hash part (containing path and search)
12381 * @returns {*} current value if used as getter or itself (chaining) if used as setter
12382 */
12383 this.hashPrefix = function(prefix) {
12384 if (isDefined(prefix)) {
12385 hashPrefix = prefix;
12386 return this;
12387 } else {
12388 return hashPrefix;
12389 }
12390 };
12391
12392 /**
12393 * @ngdoc method
12394 * @name $locationProvider#html5Mode
12395 * @description
12396 * @param {(boolean|Object)=} mode If boolean, sets `html5Mode.enabled` to value.
12397 * If object, sets `enabled`, `requireBase` and `rewriteLinks` to respective values. Supported
12398 * properties:
12399 * - **enabled** – `{boolean}` – (default: false) If true, will rely on `history.pushState` to
12400 * change urls where supported. Will fall back to hash-prefixed paths in browsers that do not
12401 * support `pushState`.
12402 * - **requireBase** - `{boolean}` - (default: `true`) When html5Mode is enabled, specifies
12403 * whether or not a <base> tag is required to be present. If `enabled` and `requireBase` are
12404 * true, and a base tag is not present, an error will be thrown when `$location` is injected.
12405 * See the {@link guide/$location $location guide for more information}
12406 * - **rewriteLinks** - `{boolean}` - (default: `true`) When html5Mode is enabled,
12407 * enables/disables url rewriting for relative links.
12408 *
12409 * @returns {Object} html5Mode object if used as getter or itself (chaining) if used as setter
12410 */
12411 this.html5Mode = function(mode) {
12412 if (isBoolean(mode)) {
12413 html5Mode.enabled = mode;
12414 return this;
12415 } else if (isObject(mode)) {
12416
12417 if (isBoolean(mode.enabled)) {
12418 html5Mode.enabled = mode.enabled;
12419 }
12420
12421 if (isBoolean(mode.requireBase)) {
12422 html5Mode.requireBase = mode.requireBase;
12423 }
12424
12425 if (isBoolean(mode.rewriteLinks)) {

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
serverBaseFunction · 0.70
stripHashFunction · 0.70
stripFileFunction · 0.70
nodeName_Function · 0.70
urlResolveFunction · 0.70
trimEmptyHashFunction · 0.70

Tested by

no test coverage detected