$locationProvider
Configure URL mode and hash-prefix behavior for $location.
Use $locationProvider during module configuration to choose how AngularTS reads
and writes browser URLs.
Exact provider members are documented in TypeDoc:
HTML5 Mode
HTML5 mode uses the History API for clean URLs. Server routing must return the application shell for deep links.
angular.module('app', []).config(($locationProvider) => {
$locationProvider.html5ModeConf = {
enabled: true,
requireBase: false,
rewriteLinks: true,
};
});
Hash Prefix
Hash mode keeps application state after the # fragment. Configure the prefix
when you need hashbang-style URLs or compatibility with existing links.
angular.module('app', []).config(($locationProvider) => {
$locationProvider.hashPrefixConf = '!';
});
See also $location.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.