我是angularJS的新手我无法在POST函数后显示我从后端获得的前端响应,实际上post函数工作正常但我无法得到响应.then()
函数不工作。
控制器:
$scope.AddNewDepartment = function() { //my function in controller.js
var PostDeptDetails = { //variable to post a data in database
organization_id: OrgId,
department_name: $scope.DepartmentText
};
MasterCreationFactory.PostDepartment(PostDeptDetails).then(function(response) { //MasterCreationFactory-My factory service name
alert(response);
});
};
我在警报中得到任何回复我也尝试了response.data
。
SERVICES:
MasterCreationFactory.PostDepartment = function(PostDeptDetails) { //MasterCreationFactory -factory name in service.js
return $http({
method: 'POST',
url: baseurl + '/Department',
headers: {
'Content-Type': 'application/json'
},
data: PostDeptDetails
});
};