8ae24f57
Geoffrey PREUD'HOMME
Liste des membres
|
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
// when landing on the page, get all Nerds and show them
$http.get('/api/nerds')
.success(function (data) {
$scope.nerds = data;
console.log(data);
})
.error(function (data) {
console.log('Error: ' + data);
});
// when submitting the add form, send the text to the node API
$scope.createNerd = function () {
console.log('Adding', $scope.formData);
$http.post('/api/nerds', $scope.formData)
.success(function (data) {
$scope.formData = {}; // clear the form so our user is ready to enter another
$scope.nerds = data;
})
.error(function (data) {
console.log('Error: ' + data);
});
};
// delete a Nerd after checking it
$scope.deleteNerd = function (id) {
$http.delete('/api/nerds/' + id)
.success(function (data) {
$scope.nerds = data;
console.log(data);
})
.error(function (data) {
console.log('Error: ' + data);
});
};
|