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