javascript - How to use res.render data as a $scope object in angular controller ? -


i have route defined in node/express has res.render

router.get('/',     function (req, res) {         res.render('index', {user: req.user});     }); 

on rendering index page, want capture req.user $scope object in angular controller on front end. how can done?

please provide code snippets answer.

to accomplish this, first need add line in jade create global javascript object hold user value, i.e.

script(text/javascript).   var theuser = !{json.stringify(user)}; // inserted jade 

now in controller this

app.controller('anycontroller',function() {     var vm = this;     vm.user = theuser;  }); 

i have done few projects.

aaron


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -