1. GET
var successCallback = function(response) { $scope.kerberos = response.data.Kerberos; if ($scope.kerberos == "disabled") { $log.info('kerberos is disabled.'); } else { $log.info('kerberos is enbaled.'); } }; var errorCallback = function(response) { $scope.error = response.data; }; $http({ method: 'GET', url: '/api/v1.0/configuration/kerberos' }) .then(successCallback, errorCallback);
2. POST
$scope.addDevice = function($event) { if($scope.addDevice.password != $scope.addDevice.confirmPassword) { alert("Passwords Don't Match"); return false; } var successCallback4addDevice = function(response) { $log.info('Device', response.data.id); eventBus.emit('backup:adddevice:off', response); }; var errorCallback4addDevice = function(response) { eventBus.emit('backup:adddevice:off', response); }; var dataobj = { username: $scope.addDevice.user, hostname: $scope.addDevice.server, path: $scope.addDevice.storage }; if ($scope.kerberos == "disabled") { $log.info('create password obj'); dataobj.password = $scope.addDevice.password; } else { $log.info('create kerberoscc obj'); dataobj.kerberoscc = $scope.addDevice.kerberoscc; } eventBus.emit('backup:adddevice:on'); $http({ method: 'POST', url: '/api/v1.0/configuration/backup-devices', data: dataobj }) .then(successCallback4addDevice, errorCallback4addDevice); };