I have a problem and I'm looking for a solution to figure out it. In ExpressJS 4 I'm using Jade as template engine and AngularJS as client side framework. I get through mongoose module a list of car brands in my mongodb. Everything works. The problem is if I call render along with json.stringify, the browser hungs and I don't get any page. Which could be the best way to pass a json and at the same time render a jade file? The next move would be to create a service to the client side and get the json in order to pass it to the view
exports.index = function(req, res, next){
Car.find()
.sort({brand:1})
.select('brand')
.exec(function(err, brand){
if(err) return next(err);
//res.json(brand);
res.render('index',
JSON.stringify(brand),
{pageTitle: 'Home'});
});
};
I have just found three good and different solution to my own problem
http://www.mircozeiss.com/how-to-pass-javascript-variables-from-a-server-to-angular/