← Back to Upcase

Angular - Managing hashtags


(Charlieanna ) #1

I am trying to make a rails api app with a angular frontend. I am using the angular routes. I want to know how to manage the hashtags. For example i want the url to be /dashboard instead of #/dashboard.


(Bassam Ismail) #2

You need to add $locationProvider in your router configurations.

app.config(['$routeProvider', '$locationProvider, function($routeProvider, $locationProvider) {
    // enables html5 pushstate, so no # in url
    $locationProvider.html5Mode(true);

    $routeProvider
        .when('/', {template: 'Homepage'})
        .when('/about', {template: 'About'})
        .otherwise({redirectTo: '/')
});

(Charlieanna ) #3

but doing this disables the routing somehow and it hits the rails http request as it normally happens