Files
web2.0-backend/members/static/js/application_controllers.js
T
2016-09-15 18:26:16 +03:00

44 lines
1.2 KiB
JavaScript

//app
app = angular.module('applicationApp', []);
//tokens
app.config(['$httpProvider', function ($httpProvider) {
$httpProvider.defaults.xsrfCookieName = 'csrftoken';
$httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken';
}]);
//helpers
function notyfication(type,timeout){
return function(msg){
noty({
'text': msg,
'layout': "bottomRight",
'type': type,
'timeout': timeout
});
};
}
var notyError = notyfication('error',2500);
var notySuccess = notyfication('success',2500);
//controllers
app.controller("applicationController", function($scope, $http, $location, $window) {
$scope.firstName = "";
$scope.lastName = "";
$scope.email = "";
//$scope.year = "1";
$scope.AYY = "";
$scope.JAS = "";
$scope.POR = "";
$scope.send = function() {
$http.post("/members/api/request", {"first_name":$scope.firstName, "last_name":$scope.lastName, "email":$scope.email, /*"year":$scope.year,*/ "AYY":$scope.AYY, "jas":$scope.JAS, "POR":$scope.POR}).then(function(data){
notySuccess("Hakemus lähetetty!");
$window.location.href = "/application/";
//$route.reload();
});
}
});