Skip to content

Instantly share code, notes, and snippets.

@suriyaJaay
Created November 15, 2016 06:03
Show Gist options
  • Save suriyaJaay/f72843cc19de1b7cc221cd178498865b to your computer and use it in GitHub Desktop.
Save suriyaJaay/f72843cc19de1b7cc221cd178498865b to your computer and use it in GitHub Desktop.
could anyone tell me how to push db values to array - MEAN stack?
Am trying to create email app with MEAN stack.
from the list i just want to send same mail to selected(checkbox using here to select) contact from list of contacts.
For mail am using node mailer.
see below code
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>
Am trying to create email app with MEAN stack. from the list i just want to send same mail to selected(checkbox using here to select) contact from list of contacts.For mail am using node mailer.
see below code
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);
})
});
if anything wrong means kindly tell how to fix it. helps much apprecaited.
thanks in advance/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment