47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
|
|
app.controller("getController", function($scope, $http, $window, $location){
|
|
$scope.members = [];
|
|
$http.get("/members/api/members").then(function(response){
|
|
$scope.members = response.data;
|
|
});
|
|
$scope.delete_member = function(id) {
|
|
$http({
|
|
url:"/members/api/member/" + id,
|
|
method:"DELETE",
|
|
csrfHeaderName:"X-CSRFToken",
|
|
csrfCookieName:"csrftoken"
|
|
}).then(
|
|
function(response) {
|
|
$window.alert("Onnistui! Hyvä Harry!");
|
|
$location.path("#/list");
|
|
},
|
|
function(response) {
|
|
$window.alert("Epäonnistui. Yritä uudelleen.");
|
|
$location.path("#/list");
|
|
}
|
|
);
|
|
};
|
|
});
|
|
|
|
app.controller("postController", function($scope, $http) {
|
|
$scope.firstName = "";
|
|
$scope.lastName = "";
|
|
$scope.email = "";
|
|
$scope.AYY = "";
|
|
$scope.JAS = "";
|
|
$scope.POR = "";
|
|
$scope.send = function() {
|
|
$http.post("/members/api/member", {"first_name":$scope.firstName, "last_name":$scope.lastName, "email":$scope.email, "AYY":$scope.AYY, "jas":$scope.JAS, "POR":$scope.POR});
|
|
}
|
|
});
|
|
app.controller("editController", function($scope, $http, $route, $routeParams) {
|
|
$scope.member = {"id": $routeParams.id};
|
|
$http.get("/members/api/member/"+$scope.member.id).then(function(response){
|
|
scope.member = response.data;
|
|
});
|
|
|
|
$scope.send = function() {
|
|
$http.put("/members/api/member", $scope.member);
|
|
}
|
|
});
|