然后功能在我的控制器中无法正常工作

时间:2015-11-12 06:52:46

标签: angularjs

我是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
    });
};

0 个答案:

没有答案