blai / grunt-express-angular-example

Sample app that shows the usage of grunt-express v1.0
65 stars 30 forks source link

Html 5 Mode #2

Open claydiffrient opened 11 years ago

claydiffrient commented 11 years ago

Turning on HTML 5 mode via $locationProvider.html5Mode(true); in the app.js causes Angular routes to be completely unavailable.

Is there a work around for this?

blai commented 11 years ago

Yes.

Currently, this sample app serve all static contents including angular.js, html, css, and other browser side javascript using a express.static middleware, hence the index.html can only be loaded through http://localhost:9000/index.html or http://localhost:9000/. In order to serve html5 mode, the web server needs to output the content of index.html for any uri, which requires a tightly coupled client-server app using express and angular. I will try to put an example together to demonstrate this.

claydiffrient commented 11 years ago

That would be great to have. I'm working on developing an application that would have a very tight coupling as you mentioned. I really like using express for RESTful API creation on the server, then being able to use those through Angular's $resource service. I'm just trying to find a way to do so without the # needing to be there.

blai commented 11 years ago

actually, you may want to try this first: http://stackoverflow.com/questions/16569841/angularjs-html5-mode-reloading-the-page-gives-wrong-get-request I was going to write the middleware and found someone already did it.

claydiffrient commented 11 years ago

That's interesting. Should I convert all references to express to make it work as well as placing it in the express grunt task?