Using node express and angular, I have set up a route in my express app.js where I pass a variable to the rendered page:
app.get('/test', function(req, res){
res.render('test', { user: 12345 });
});
Within my 'test' view, I establish a connection to angular by utilizing ng-controller:
<div ng-controller='testCtrl'> <!--some markup here--> </div>
In my angular controllers.js file, I define a function for my view like this:
function testCtrl($scope) {
/*...some code here...*/
}
The question now arises - how can I access the 'user' variable that was passed into the view from express within my controller function?