no console.log answer while posting

岁酱吖の 提交于 2020-01-16 11:59:39

问题


Front-End

app.factory('CustomerService', function($http) {
    return {
        addCustomerToDb : function(customer) {
            return  $http.post('localhost:4000/new_info', customer)
                .success(function(response) {
                    //alert(JSON.stringify(data))
                    console.log(response.customer)
                });

            //   return $http({
            //     method:"POST",
            //     url: "localhost:4000/new_info",
            //     customer:customer
            // });
        }
    }   
});

app.controller("new_info", function($scope, CustomerService, $routeParams) {    
    $scope.register = function () {
        CustomerService.addCustomerToDb($scope.customer)
            .then(function(response) {
                console.log(response.$scope.customer);
            });
    };

});

来源:https://stackoverflow.com/questions/52067133/no-console-log-answer-while-posting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!