You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

41 lines
1.4 KiB

app.controller('PersonalController', function($scope, $cookieStore, $http, $filter, $modal) {
if(typeof($cookieStore.get('user')) != "undefined"){
$scope.user = $cookieStore.get('user');
}
$http({
method: 'GET',
url: serverURL+"/personals/",
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
}).success(function(data, status, headers, config) {
if(data.success == "true"){
$scope.list = data.personals;
}else{
modal = modalCreate($modal,"danger", "Error", "It has successfully made the connection but something went wrong");
}
}).error(function(data, status, headers, config) {
modal = modalCreate($modal,"danger", "Error", "Not connected with server.");
});
$scope.removePersonal = function(personal){
var basket = $cookieStore.get('basket');
$http({
method: 'POST',
url: serverURL+"/personals/delete",
data: {
personal: personal,
user: $scope.user
},
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
}).success(function(data, status, headers, config) {
if(data.success == "true"){
var index = $scope.list.indexOf(personal)
$scope.list.splice(index, 1);
}else{
modal = modalCreate($modal,"danger", "Error", "It has successfully made the connection but something went wrong");
}
}).error(function(data, status, headers, config) {
modal = modalCreate($modal,"danger", "Error", "Not connected with server.");
});
};
});