2

I just start to learn angularJs, and was trying to configure the partial page with angular route service.

It worked with the hash format, however,when I tried to get rid of hash, the routeProvider stopped working.

JS

app.config(function($routeProvider,$locationProvider){ $locationProvider.html5Mode(true); $routeProvider.when("/", { templateUrl: "/index.html" }). when("/about", { templateUrl: "/partials/about.html" }). when("/contact", { templateUrl: "/partials/contact.html" }). otherwise({ redirectTo: '/' }); }); 

HTML

 <ul class="nav navbar-nav navbar-right"> <li><a href="/about">About</a></li> <li><a href="/contact">Contact</a></li> </ul 

Can someone enlighten me?

2
  • How did it stop working? Does clicking on the links do nothing now? Does it cause a 404? Does it produce any messages on the error console? Commented Dec 20, 2013 at 7:32
  • No content in ng-view part. Can not load the partial page Commented Dec 20, 2013 at 19:11

1 Answer 1

6

Try to change

 $locationProvider.html5Mode(true); 

to

$locationProvider.html5Mode(true).hashPrefix('!'); 

And add

<base href="/"> 

in a document "head" section.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.