【发布时间】:2013-08-19 06:47:23
【问题描述】:
查看页面:
<div ng-controller="LoginCtrl">
<form name="login_form" ng-submit="submit()" >
Email: <input type="email" ng-model="login.email" required/><br />
Password: <input type="password" ng-model="login.pass" required/><br />
<input type="submit" />
</form>
main.js
function LoginCtrl($scope, $http) {
$scope.login = {};
$scope.submit = function(){
$http({
method: 'POST',
url: '/login',
data: $scope.login,
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}).
success(function(response) {
window.location.href = "/login";
}).
error(function(response) {
$scope.codeStatus = response || "Request failed";
});
}
登录控制器:
if ($request->isPost()) {
$data = json_decode(file_get_contents("php://input"));}
我需要从 Angular 表单中获取数据并将其传递给 zend 控制器并执行登录检查并提交表单。有人可以帮助逐步解释吗?
【问题讨论】:
-
要成为有效的 HTTP POST,您不需要在 JSON 提交中附加 HTML 名称吗?在登录控制器中,添加
error_log( file_get_contents("php://input") ); -
这个问题似乎是题外话,因为它是关于辅导
标签: php angularjs zend-framework2