title: MEAN Stack - Pass form from Angular to Express to be emailed by Nodemailer
body: <p>I am pretty new to the MEAN stack and am trying to send the values from a content form that is processed by Angular JS on the front-end and then passed to Express on the backend to be sent as an email by Nodemailer.</p>
  
  <p>I am having issues with the routing from Angular to Express and the documentation seems to be pretty sparse for this stack. Also I am assuming I would use node mailer to send the email, any info or best practices on that would also be appreciated.</p>
  
  <p>My app.js</p>
  
  <pre><code>var express = require('express');
  var routes = require('./routes');
  
  var user = require('./routes/user');
  var contact = require('./routes/contact');  // Contact Form
  var http = require('http');
  var path = require('path');
  
  var app = express();
  var nodemailer = require("nodemailer");
  
  // all environments
  app.set('port', process.env.PORT || 3000);
  app.set('views', path.join(__dirname, 'views'));
  app.set('view engine', 'jade');
  app.use(express.favicon());
  app.use(express.logger('dev'));
  app.use(express.json());
  app.use(express.urlencoded());
  app.use(express.methodOverride());
  app.use(app.router);
  app.use(express.static(path.join(__dirname, 'public')));
  
  // development only
  if ('development' == app.get('env')) {
    app.use(express.errorHandler());
  }
  
  app.get('/', routes.index);
  app.get('/users', user.list);
  app.post('/contact', contact.process);  // Contact form route
  
  
  http.createServer(app).listen(app.get('port'), function(){
    console.log('Express server listening on port ' + app.get('port'));
  });
  </code></pre>
  
  <p>My contact.js</p>
  
  <pre><code>exports.post('/contact', function(req, res) {
  console.log('I Made it to Express');
  process(req, res);
  });
  </code></pre>
  
  <p>My Angular Controller</p>
  
  <pre><code>app.controller('contactController', function($scope, $http, $location) {
  $scope.formData = {};
  
  $scope.processForm = function() {
      console.log('Im in the controller');
  
      // Trigger validation flag.
      $scope.submitted = true;
  
      $http.post('/contact', {
          name: $scope.formData.name,
          email: $scope.formData.email,
          message: $scope.formData.message
      }).success(function(data, status, headers, config) {
              if(data.success){
                  $location.path('/');
              }else {
                  //do something about the error
              }
          });
  };
  
  });
  </code></pre>
  
  <p>And finally my Angular app</p>
  
  <pre><code>'use strict';
  var app = angular.module('app', ['ngRoute']).config(function($routeProvider, $locationProvider) {
  
  
  // Route: Default Widget View
  $routeProvider.when('/contact', {
      controller: 'contactController'
  });
  
  
  });
  </code></pre>
  
  <p>The error I am seeing is in the contact.js - TypeError: Object # has no method 'post'</p>
  
  <p>Here is my folder structure:
  <img src="https://i.stack.imgur.com/aT9pd.png" alt="enter image description here"></p>