Niezborala Niezborala - 11 months ago 86
Javascript Question

How to delete '#' sign in angular-ui-router URLs

I'm using angular-ui-router library and I have probelm with URLs.

I have following code:


app.config(function ($stateProvider, $urlRouterProvider) {
.state('state', {
url: '/state',
templateUrl: 'templates/state.html',
onEnter: function () {
/*... code ...*/


<a href="#/state">STATE</a>

and this works, but when i delete '#' from
tag this dosn't work.

And here I have question, how to delete '#' sign from URL?


You need to enable HTML5Mode if you want navigation without hash tags:

app.config(["$locationProvider", function($locationProvider) {

Beward that support for HTML5 mode depends on the browser. For those who don't support the History API, Angular will fallback to hashbang.