我有一个表单,当我提交它时,另一个表单会用单选按钮显示,这些按钮是其他数据。我选择一个并提交它。我希望将数据显示在另一个页面中,但它不会显示我所做的任何事情。
因此,有一个/form路由,我希望在上次提交之后,用我的数据在/confirmation路由上重定向。
Bellow是我在angularjs的formController
.controller('formController', ['$scope', '$http', '$location', function($scope, $http, $location) {
$scope.pageClass = 'form';
$scope.firstName = '';
$scope.lastName = '';
$scope.email = '';
$scope.departure = '';
$scope.destination = '';
$scope.submitFirstForm = function() {
$http.post('/form', {
firstName: $scope.firstName,
lastName: $scope.lastName,
email: $scope.email,
departure: $scope.departure,
destination: $scope.destination,
}).then(function(res) {
$scope.response = res.data;
});
}
$scope.submitConfirmationForm = function(flight){
$http.post('/confirmation', {
departure: $scope.departure,
destination: $scope.destination
}).then(function(res) {
$scope.otherResponse = res.data;
$location.path("/confirmation");
});
};
}]);Bellow是我的特快专递功能,仅适用于/CONFIRMATION路由
app.post("/confirmation",function(req,res)
{
var departure=req.body.departure;
var destination=req.body.destination;
otherResponse = {
"confirmation": [{
"departure": departure,
"destination": destination,
"msg": "MSG OK",
}]
};
res.json(otherResponse);
});最后,大声喊出我的confirmation.html,看看我的json otherReponse是怎么回事
<pre>
{{otherResponse | json}}
</pre>发布于 2016-03-21 12:28:28
您没有传递“值”,您需要这样做:
$location.path(‘/确认/’).search({param:'otherResponse'});
$location方法是可链接的。
这种产品:
/确认/?param=其他答复
检查文档中的$location
https://stackoverflow.com/questions/36130703
复制相似问题