如何将db值推送到数组 - MEAN堆栈

时间:2016-11-15 05:28:45

标签: javascript angularjs mean-stack nodemailer

我正在尝试使用MEAN堆栈创建电子邮件应用。从列表中我只想发送相同的邮件到选中(复选框使用此处选择)联系人列表中的联系人。对于使用节点邮件的邮件。

见下面的代码

中将Html.HTML

 <tr class='danger'>
                        <td>Name</td>
                        <td>Email</td>
                        <td>Number</td>
                        <td>Edit</td>
                        <td>Delete</td>
                        <td>Select All
                            <input type="checkbox" ng-model="selectedAll" ng-click="selectAll()" class="pull-right" />
                        </td>
                    </tr>

    <td>
                            <input type="checkbox" class="pull-right" ng-model="person.Selected" ng-click="checkIfAllSelected()" />
                        </td>

myModl.js

  angular.module('mailContacts', ['ui.bootstrap']);
  var modalControl = function($scope, $modal, $log) {
      var key = 1000;
      $scope.items = ['item1', 'item2', 'item3'];
      $scope.open = function(person) {
          var modalInstance = $modal.open({
              templateUrl: 'e.html',
              controller: itemCtrl,
              resolve: {
                  items: function() {
                      return $scope.persons;
                  },
                  key: function() {
                      return key;
                  }
              }
          });
          modalInstance.result.then(function(selectedItem) {
              $scope.selected = selectedItem;
          }, function() {});
      };
  };

listController.js

     //getting all contacts in list
        var onAddressGetCompleted = function(response){
            $scope.addresses = response.data;
            console.log($scope.addresses);
        }
          //select and deselect items in list
                    $scope.selectAll = function() {
                        angular.forEach($scope.persons, function(person) {
                            person.Selected = $scope.selectedAll;
                        });
                    };
                    $scope.checkIfAllSelected = function() {
                        $scope.selectedAll = $scope.persons.every(function(person) {
                            return person.Selected == true
                        })
                    };

server.js

    app.get('/persons', function(req, res) {
        console.log('Received find all persons request');
        db.Persons.find(function(err, docs) {
            console.log(docs);
            res.json(docs);
        })
    });

    app.get('/person/:id', function(req, res) {
        console.log('Received findOne person request');
        db.Persons.findOne({ _id: new mongojs.ObjectId(req.params.id) }, function(err, docs) {
            console.log(docs);
            res.json(docs);
        })
    });

请告诉我如何向选定的联系人发送电子邮件

非常感谢。

0 个答案:

没有答案