Я пытался использовать $ http для передачи угловых данных в php, но по приведенному ниже коду в качестве переменной $ message возвращается весь HTML-код, а не нужные данные, пожалуйста, не стесняйтесь поделиться своими мыслями, большое спасибо!
PHP код
<?php
echo "
<body>
<section class=\"contact-form\">
<table width=\"100%\">
<tr>
<td colspan=\"2\">
<label for=\"message\">Message:</label>
<textarea class=\"form-control\" rows=\"5\" id=\"message\" ng-model=\"message\"></textarea>
</td>
</tr>
</table>
<button type=\"button\" class=\"btn btn-danger btn-block buttonSubmit\" >Send Email</button>
</div>
</div>
</section>
<script type=\"text/javascript\" src=\"js/contact.js\"></script>
</body>";
$from_angular = json_decode( file_get_contents('php://input'));
echo "<script>console.log('connect = ".$from_angular."');</script>";
$message = $from_angular->message;
echo "<script>console.log('message = ".$message."');</script>";
?>
угловой код
var contact = angular.module('contact-form',[]);
contact.controller('Ctrl', function($scope, $http){
$scope.message = 'Today I would like to inform you that your work is pretty impressive. Hope we could get contact to each other and furtherly talk about a precious working position in my company. This position is related to Software Development, which is a perfect fit to your professional background.';
$http({
url: "./Contact.php",
method: "GET",
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
data: {
message: $scope.message,
}
}).success(function(data) {
console.log(data);
});
})