javascript - AngularJS Not Loading on Other Paths -
i sure has been answered before, have no idea how phrase this, not able find on google.
i writing website using node.js, express, , angular. angular app loads when visit home page 127.0.0.1:8080
. when click link review (say 127.0.0.1:8080/review/8ja9d8kkjnmd
), route next controller , next page in angular app. however, if manually enter url , press enter, node.js api serves me json serve angular app.
so angular app takes json , renders view. how still load angular page manually entering url , not ping node api?
i feel common problem, , again apologize because sure has been answered time , time again.
this structure angular app
public/js ├── app.js ├── approutes.js ├── controllers │ ├── mainctrl.js │ └── reviewctrl.js ├── views │ ├── index.html │ ├── home.html │ └── review.html └── services ├── mainservice.js └── reviewservice.js
app.js is:
// public/js/app.js angular.module('sampleapp', ['ngroute', 'approutes', 'mainctrl','mainservice','reviewctrl','reviewservice','underscore']);
approutes.js is:
// public/js/approutes.js angular.module('approutes', []).config(['$routeprovider', '$locationprovider', function($routeprovider, $locationprovider) { $routeprovider // home page .when('/', { templateurl: 'views/home.html', controller: 'maincontroller' }) .when('/review/:review_id', { templateurl: 'views/review.html', controller: 'reviewcontroller' }) .otherwise({redirectto: '/'}); $locationprovider.html5mode(true); }]);
if there more code need post, let me know.
i tried comment can't. question answered here. when modehtml5 enabled, browser no way of knowing if path correct. recomeindo read previous post
ps: sorry english