grunt-express-angular-example
grunt-express-angular-example copied to clipboard
Html 5 Mode
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?
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.
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.
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.
That's interesting. Should I convert all references to express to make it work as well as placing it in the express grunt task?