title: How to display express-validator errors using angular?
body: <p>I'm trying to figure out how to use the <em>express-validator</em> together with angularjs and html to display validation errors, my problem is im not able to get access to the <em>errors</em> variable. See code below.</p>
  
  <p><em>routes.js</em> </p>
  
  <pre><code>router.post('/register', function(req, res){
   var name = req.body.name;
   var email = req.body.email;
   var username = req.body.username;
   var password = req.body.password;
   var password2 = req.body.password2;
  
   req.checkBody('name', 'Name is required').notEmpty();
   req.checkBody('email', 'Email is required').notEmpty();
   req.checkBody('email', 'Email not valid').isEmail();
   req.checkBody('username', 'Username is required').notEmpty();
   req.checkBody('password', 'Password is required').notEmpty();
   req.checkBody('password2', 'Passwords does not match').equals(req.body.password);
  
   var errors = req.validationErrors();
  
   if(errors){
       res.render('register.html', {
           errors: errors
       });
   } else {
       console.log('no errors');
   }})
  </code></pre>
  
  <p>I found what seems to be the problem, in my <em>server.js</em>.
  This seem to be causing problems between the express and angular routes, making the express routing fail and therefor not passing data as wanted. See below.</p>
  
  <pre><code>app.use(function(req, res){
  res.sendFile(__dirname + '/app/index.html');
  });
  app.use('/', routes);
  app.use('/user', users);
  </code></pre>
  
  <p>If i try this, see below.</p>
  
  <pre><code>app.use('/', routes);
  app.use('/user', users);
  app.use(function(req, res){
  res.sendFile(__dirname + '/app/index.html');
  });
  </code></pre>
  
  <p>This makes the express routing passing data as i want to, but my angular routing seem to be bugging, once i refresh the page- the view fails to load correctly.</p>
  
  <p>However, i do know how to display this using either ejs or handlebars but this doesnt fit my needs, there should be a way to store the errors with angular and displaying it with html somehow right?</p>
  
  <p>Any help is appreciated!</p>