MCPcopy Create free account
hub / github.com/EricSimons/ionic-course / $LocationProvider

Function $LocationProvider

code/songhop/www/lib/angular/angular.js:11132–11411  ·  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

11130 * Use the `$locationProvider` to configure how the application deep linking paths are stored.
11131 */
11132function $LocationProvider() {
11133 var hashPrefix = '',
11134 html5Mode = {
11135 enabled: false,
11136 requireBase: true,
11137 rewriteLinks: true
11138 };
11139
11140 /**
11141 * @ngdoc method
11142 * @name $locationProvider#hashPrefix
11143 * @description
11144 * @param {string=} prefix Prefix for hash part (containing path and search)
11145 * @returns {*} current value if used as getter or itself (chaining) if used as setter
11146 */
11147 this.hashPrefix = function(prefix) {
11148 if (isDefined(prefix)) {
11149 hashPrefix = prefix;
11150 return this;
11151 } else {
11152 return hashPrefix;
11153 }
11154 };
11155
11156 /**
11157 * @ngdoc method
11158 * @name $locationProvider#html5Mode
11159 * @description
11160 * @param {(boolean|Object)=} mode If boolean, sets `html5Mode.enabled` to value.
11161 * If object, sets `enabled`, `requireBase` and `rewriteLinks` to respective values. Supported
11162 * properties:
11163 * - **enabled** – `{boolean}` – (default: false) If true, will rely on `history.pushState` to
11164 * change urls where supported. Will fall back to hash-prefixed paths in browsers that do not
11165 * support `pushState`.
11166 * - **requireBase** - `{boolean}` - (default: `true`) When html5Mode is enabled, specifies
11167 * whether or not a <base> tag is required to be present. If `enabled` and `requireBase` are
11168 * true, and a base tag is not present, an error will be thrown when `$location` is injected.
11169 * See the {@link guide/$location $location guide for more information}
11170 * - **rewriteLinks** - `{boolean}` - (default: `true`) When html5Mode is enabled,
11171 * enables/disables url rewriting for relative links.
11172 *
11173 * @returns {Object} html5Mode object if used as getter or itself (chaining) if used as setter
11174 */
11175 this.html5Mode = function(mode) {
11176 if (isBoolean(mode)) {
11177 html5Mode.enabled = mode;
11178 return this;
11179 } else if (isObject(mode)) {
11180
11181 if (isBoolean(mode.enabled)) {
11182 html5Mode.enabled = mode.enabled;
11183 }
11184
11185 if (isBoolean(mode.requireBase)) {
11186 html5Mode.requireBase = mode.requireBase;
11187 }
11188
11189 if (isBoolean(mode.rewriteLinks)) {

Callers

nothing calls this directly

Calls 11

stateMethod · 0.80
isDefinedFunction · 0.70
isBooleanFunction · 0.70
isObjectFunction · 0.70
serverBaseFunction · 0.70
stripHashFunction · 0.70
nodeName_Function · 0.70
urlResolveFunction · 0.70
afterLocationChangeFunction · 0.70
trimEmptyHashFunction · 0.70

Tested by

no test coverage detected