Advertisement
Guest User

Untitled

a guest
Aug 29th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. var common = require('../common');
  2.  
  3. var inviteeSchema = common.Schema({
  4. email: String
  5. });
  6. var Invite = common.conn.model('Invite', inviteeSchema);
  7. module.exports = Invite;
  8.  
  9. router.route('/addtoinvitelist').post(function (req, res, next) {
  10.  
  11. var invite =new Invite(req.body);
  12.  
  13. invite.save(function(err,email){
  14. if(err) throw err;
  15.  
  16. res.json({message:"your mail id is stored in our database we will soon send you an invite"})
  17. });
  18. });
  19.  
  20. <form action="#">
  21. <div class="form-group">
  22. <label for="subcribeNewsletter" class="control-label">INVITE FORM<br> <small>We are happy to invite you to medicoshere, So please enter your email ID in the below form.</small></label>
  23. <div class="input-group input-group-in input-group-sm">
  24. <div class="input-group-addon"><i class="fa fa-envelope text-belpet"></i></div>
  25. <input class="form-control" id="subcribeNewsletter" placeholder="name@mail.com" ng-model="useremail" required>
  26. <div class="input-group-btn">
  27. <button type="submit" class="btn btn-default text-belpet" ng-click="AddToInviteList(useremail)"><strong>OK</strong></button>
  28. </div>
  29. </div>
  30. </div><!-- /.form-group -->
  31. </form><!-- /form -->
  32.  
  33. $http({
  34.  
  35. method: 'POST',
  36. url: "http://localhost:3000/users/addtoinvitelist",
  37. headers: {
  38. 'Content-Type': 'application/x-www-form-urlencoded'
  39. }, // set the headers so angular passing info as form data (not request payload)
  40. data:"email"
  41.  
  42. }).success(function (data) {
  43.  
  44. console.log("email is posted sucessfully" + data);
  45. cb(data);
  46. })
  47.  
  48. }`
  49.  
  50. App.controller('InviteController', function ($scope, $rootScope, $routeParams, $location, UserServices) {
  51. $scope.init = function () {
  52. console.log("hii this is a test ")
  53. };
  54.  
  55.  
  56. $scope.email = {};
  57.  
  58. $scope.AddToInviteList = function () {
  59.  
  60. UserServices.AddToInviteList($scope.email, function (dataresponse) {
  61.  
  62.  
  63. console.log(dataresponse);
  64.  
  65. })
  66.  
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement