* @ngdoc provider * @name $locationProvider * @description * Use the `$locationProvider` to configure how the application deep linking paths are stored.
()
| 12794 | * Use the `$locationProvider` to configure how the application deep linking paths are stored. |
| 12795 | */ |
| 12796 | function $LocationProvider() { |
| 12797 | var hashPrefix = '', |
| 12798 | html5Mode = { |
| 12799 | enabled: false, |
| 12800 | requireBase: true, |
| 12801 | rewriteLinks: true |
| 12802 | }; |
| 12803 | |
| 12804 | /** |
| 12805 | * @ngdoc method |
| 12806 | * @name $locationProvider#hashPrefix |
| 12807 | * @description |
| 12808 | * @param {string=} prefix Prefix for hash part (containing path and search) |
| 12809 | * @returns {*} current value if used as getter or itself (chaining) if used as setter |
| 12810 | */ |
| 12811 | this.hashPrefix = function(prefix) { |
| 12812 | if (isDefined(prefix)) { |
| 12813 | hashPrefix = prefix; |
| 12814 | return this; |
| 12815 | } else { |
| 12816 | return hashPrefix; |
| 12817 | } |
| 12818 | }; |
| 12819 | |
| 12820 | /** |
| 12821 | * @ngdoc method |
| 12822 | * @name $locationProvider#html5Mode |
| 12823 | * @description |
| 12824 | * @param {(boolean|Object)=} mode If boolean, sets `html5Mode.enabled` to value. |
| 12825 | * If object, sets `enabled`, `requireBase` and `rewriteLinks` to respective values. Supported |
| 12826 | * properties: |
| 12827 | * - **enabled** – `{boolean}` – (default: false) If true, will rely on `history.pushState` to |
| 12828 | * change urls where supported. Will fall back to hash-prefixed paths in browsers that do not |
| 12829 | * support `pushState`. |
| 12830 | * - **requireBase** - `{boolean}` - (default: `true`) When html5Mode is enabled, specifies |
| 12831 | * whether or not a <base> tag is required to be present. If `enabled` and `requireBase` are |
| 12832 | * true, and a base tag is not present, an error will be thrown when `$location` is injected. |
| 12833 | * See the {@link guide/$location $location guide for more information} |
| 12834 | * - **rewriteLinks** - `{boolean}` - (default: `true`) When html5Mode is enabled, |
| 12835 | * enables/disables url rewriting for relative links. |
| 12836 | * |
| 12837 | * @returns {Object} html5Mode object if used as getter or itself (chaining) if used as setter |
| 12838 | */ |
| 12839 | this.html5Mode = function(mode) { |
| 12840 | if (isBoolean(mode)) { |
| 12841 | html5Mode.enabled = mode; |
| 12842 | return this; |
| 12843 | } else if (isObject(mode)) { |
| 12844 | |
| 12845 | if (isBoolean(mode.enabled)) { |
| 12846 | html5Mode.enabled = mode.enabled; |
| 12847 | } |
| 12848 | |
| 12849 | if (isBoolean(mode.requireBase)) { |
| 12850 | html5Mode.requireBase = mode.requireBase; |
| 12851 | } |
| 12852 | |
| 12853 | if (isBoolean(mode.rewriteLinks)) { |
nothing calls this directly
no test coverage detected