Made http get calls to functions

This commit is contained in:
HooVee
2016-08-15 21:45:31 +03:00
parent efcdba92bc
commit 54bbc13216
2 changed files with 24 additions and 19 deletions
+1 -1
View File
@@ -4,7 +4,7 @@
<form name="applicationForm">
<div class="form-group">
<label>Etunimi: </label>
<input id="firstNameField" required type="text" placeholder="Sähkö" class="form-control" ng-model="application.first_name"></input>
<input id="firstNameField" required type="text" placeholder="Sähkö" class="form-control" ng-model="application.member.first_name"></input>
</div>
<div class="form-group">
<label>Sukunimi: </label>
+23 -18
View File
@@ -1,13 +1,16 @@
app.controller("getController", function($scope, $http, $window, $location){
$scope.members = [];
$http.get("/members/api/members").then(function(response){
$scope.members = response.data;
// map trues and falses to more user-friendly format
_.each($scope.members, function(m){
m.jas = m.jas ? "Kyllä" : "Ei";
m.AYY = m.AYY ? "Kyllä" : "Ei";
});
});
$scope.getFunction = function() {
$http.get("/members/api/members").then(function(response){
$scope.members = response.data;
// map trues and falses to more user-friendly format
_.each($scope.members, function(m){
m.jas = m.jas ? "Kyllä" : "Ei";
m.AYY = m.AYY ? "Kyllä" : "Ei";
});
});
};
$scope.getFunction();
$scope.delete_member = function(id) {
$http.delete("/members/api/member/" + id).then(
function(response) {
@@ -26,8 +29,7 @@ app.controller("getController", function($scope, $http, $window, $location){
// ]
// http://ned.im/noty/#/about
});
$location.path("/list");
$scope.getFunction();
},
function(response) {
noty({
@@ -36,7 +38,7 @@ app.controller("getController", function($scope, $http, $window, $location){
type: "error",
timeout: 10000
});
$location.path("/list");
$scope.getFunction();
}
);
};
@@ -125,9 +127,12 @@ app.controller("editController", function($scope, $http, $route, $routeParams, $
});
app.controller("applController", function($scope, $http, $route, $routeParams, $window, $location){
$http.get("/members/api/requests").then(function(response){
$scope.applications = response.data;
});
$scope.applGetFunction = function() {
$http.get("/members/api/requests").then(function(response){
$scope.applications = response.data;
});
};
$scope.applGetFunction();
$scope.send_appl = function(id) {
$http.post("/members/api/request/" + id).then(
function(response) {
@@ -137,7 +142,7 @@ app.controller("applController", function($scope, $http, $route, $routeParams, $
type: "success",
timeout: 10000
});
$location.path("/applications");
$scope.applGetFunction();
},
function(response) {
noty({
@@ -146,7 +151,7 @@ app.controller("applController", function($scope, $http, $route, $routeParams, $
type: "success",
timeout: 10000
});
$location.path("/applications");
$scope.applGetFunction();
}
);
};
@@ -159,7 +164,7 @@ app.controller("applController", function($scope, $http, $route, $routeParams, $
type: "success",
timeout: 10000
});
$location.path("/applications");
$scope.applGetFunction();
},
function(response) {
noty({
@@ -168,7 +173,7 @@ app.controller("applController", function($scope, $http, $route, $routeParams, $
type: "success",
timeout: 10000
});
$location.path("/applications");
$scope.applGetFunction();
}
);
};