-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontrollers.js
57 lines (50 loc) · 1.33 KB
/
controllers.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
function ListCtrl($scope, $http) {
$scope.data = {message: "OHSNAPZ"};
$scope.message = "wtf4";
$http.get('/api/post').
success(function(data, status, headers, config) {
$scope.posts = data.posts;
});
}
function AddCtrl($scope, $http, $location) {
/*
console.log('omgsgsgdgsd');
$scope.form = {};
$scope.submitPost = function () {
$http.post('/api/post', $scope.form).
success(function(data) {
$location.path('/');
});
};
*/
$scope.tilt = 'ot';
}
function UpdateCtrl($scope, $http, $location, $routeParams) {
$scope.form = {};
$http.get('/api/post/' + $routeParams.id).
success(function(data) {
$scope.form = data.post;
});
$scope.editPost = function () {
$http.put('/api/post/' + $routeParams.id, $scope.form).
success(function(data) {
$location.url('/readPost/' + $routeParams.id);
});
};
}
function DeleteCtrl($scope, $http, $location, $routeParams) {
$http.get('/api/post/' + $routeParams.id).
success(function(data) {
$scope.post = data.post;
});
$scope.deletePost = function () {
$http.delete('/api/post/' + $routeParams.id).
success(function(data) {
$location.url('/');
});
};
$scope.home = function () {
$location.url('/');
};
}
angular.module('myApp').controller('ListCtrl', ListCtrl);