发布时没有console.log答案

时间:2018-08-28 22:42:58

标签: angularjs ajax console.log

前端

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

});

0 个答案:

没有答案