forked from SpectaTechnologies/med-stock
/
stockistsCtrl.js
34 lines (24 loc) · 971 Bytes
/
stockistsCtrl.js
1
2
3
4
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
angular.module('app')
.controller('stockistsCtrl', function($scope, $http) {
$scope.setup = function() {
$http.get('/api/stockists')
.then(function(response) {
$scope.model = response.data;
}, function(response) {
// called asynchronously if an error occurs
// or server returns response with an error status.
});
}
$scope.setup();
$scope.deleteStockist = function(stockist_id) {
if (!confirm('Are you sure?')) return;
$http.delete('/api/stockists/'+ stockist_id)
.then(function(response) {
console.log(response)
$scope.setup();
}, function(response) {
console.log(response)
// if error occurs
});
}
})