javascript - Enabling HTML 5 Mode in AngularJS 1.2 -
i'm working on app needs use html 5 mode. due fact migrating existing site use angularjs 1.2, cannot have '#' tags in url. currently, have following:
angular.module('myapp', ['ngroute']). config(['$routeprovider', '$locationprovider', function($routeprovider, $locationprovider) { $locationprovider.html5mode(true); $routeprovider .when("/home", {templateurl:'home.html', controller:'homecontroller'}) // other routes defined here.. .otherwise({redirectto: '/home'}); }]);
unfortunately, when visit 'http://myserver/home
', app not work when html 5 mode enabled. 404. however, when visit http://myserver/
works. deep-linking doesn't work when have html5 mode enabled. if comment out line says "$locationprovider.html5mode(true);", site functions. however, once again, cannot have hash tags in url due fact i'm migrating existing site.
am misunderstanding how html5mode(true) works? or, doing wrong?
thank you
if you're using html5mode
need make changes on server side return entry point index.html
(main app page) on url request. angular app parse url , load needed page.
Comments
Post a Comment