Created
November 15, 2016 06:03
-
-
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?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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