0
우리는 여전히 어떻게 각도 JS 작품 배우고 각 $의 HTTP에서 정의되지 않는다, 우리가 약간의 문제, 우리는 header('Content-Type:application/json;');
및 JSON으로 출력이 각PHP의 JSON 응답이
var app = angular.module('app',['ngMessages']);
app.controller('AppCntrl', function($scope, PostingService) {
$scope.submitData = function() {
var data = {
name: "abc",
email: "[email protected]"
};
PostingService.postData(data);
}
});
app.service('PostingService', ['$http',function($http) {
this.postData = function(data) {
$http.post(
'/url/to/post/request',
data
)
.then(function successCallback(response) {
alert(response); // alerts undefined ***********************
}, function errorCallback(response) {
alert(response); // alerts undefined ***********************
});
}
}]);
/url/to/post/request
동안과 http
POST 요청을하고 있습니다 응답은 {"status":true,"message":"this is message"}
과 비슷하지만 경고는 정의되지 않음을 나타냅니다.