I've been through many Angular-express seeds and kind of worked out how they work.
The problem I am having is: 1). I would like to use ejs-locals for templating. 2). How to configure correctly the routing of the server-side and client-side. And also, when entering a URL such as /about
, not to generate the error: cannot /get
angular app.js contains:
// angular stuff
$routeprovider.when('/', {
templateUrl: 'index',
controller: IndexCtrl
});
$routeprovider.when('/about', {
templateUrl: 'partials/about',
controller: IndexCtrl
});
express app,js contains:
app.get('/', routes.index);
app.get('/about', routes.about);
routes folder contains 'index.js':
exports.index = function(req, res){
res.render('index',{name:"Hello"});
};
exports.about = function (req, res) {
res.render('partials/about');
};
Views folder contains index.ejs
:
<!--HTML head/navigation bar here-->
<div ng-view></div>
and inside views folder is a partials
folder:
(Views/partials/)
index.ejs:
<h1>Index</h1>
about.ejs:
<h1>About</h1>
question from:
https://stackoverflow.com/questions/13860899/angular-and-express-routing 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…