0

Basically I'm using Angular UI routes with an app I'm building. The routes work as expected however when I try to use html5Mode as in: $locationProvider.html5Mode(true); and reload a page with a deep link, the style gets broken unless I reload from the base url.

If I reload with $locationProvider.html5Mode(false); the reload works normally.

Am I missing something here?

1 Answer 1

1

You need to add the urls to w/e you're serving up the base html file to serve up the base template when one of those urls are hit. Angular will only route locally. So the response hits your server, trys to find the correct html to serve up and probably fails.

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

3 Comments

I'm really sorry but I'm not sure I follow. So you're saying I'd need something like an htaccess file on the server level pointing all traffic to my index.html (Angular app)? Is that correct? Btw, what's w/e?
Yes that's correct. Your initial request will go to the server. The server will try to find the correct html/response object to return that correrlates with that url. Angular only uses routes locally, on client side. But first you have to serve it up :) w/e === whatever. i'm not sure what backend you're using so I can't be more helpful. BTW (by the way) html5mode wont work if you're just using a file location to serve the index.html up.
Thanks, very helpful. I'm using a Rails 4 backend btw.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.