Problems with angular and http-server routes

0

I put the $ locationProvider.html5Mode (true); on my routes to take that #! URL. I'm not sure if this is a good way to do this, but I do not know how to do this.

This happened to happen when I started using $ locationProvider.html5Mode. As a server, I'm using the link .

If you do not have a solution for this, you would like to recommend another server, other than apache. One in that style from http-server msm.

I was using ngRoute, ms I switched to test the UI router, ms n changed na

app.config(function($stateProvider, $urlRouterProvider, $locationProvider) {
$urlRouterProvider.otherwise('/');
$stateProvider
.state("home", {
    url:'/',
    templateUrl: "view/home.html"
})
.state("perfil", {
    url:'/perfil',
    templateUrl: "view/profile.html"
})
.state("portifolio", {
    url:'/portifolio',
    templateUrl: "view/portifolio.html"
})
.state("contato", {
    url:'/contato',
    templateUrl: "view/contact.html"
});
$locationProvider.html5Mode(true);
});
    
asked by anonymous 07.03.2017 / 18:14

1 answer

0

Based on this response:

  

Server side

     

Using this mode requires URL rewriting on server side, basically you have to rewrite all your links to entry point of your application (eg index.html).

Using angular html5 mode needs to have path rewrite enabled on the server, and because of the static nature of the server you are using, you do not make that angular on the server.

So what this documentation wants to report is that it is necessary to implement a url rewriting policy that can not be done on http-server so I could observe in your repository.

Use nginx, node.js + express or apache to do this.

07.03.2017 / 19:40