首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >公路之间的传递数据

公路之间的传递数据
EN

Stack Overflow用户
提问于 2016-03-21 12:12:45
回答 1查看 44关注 0票数 2

我有一个表单,当我提交它时,另一个表单会用单选按钮显示,这些按钮是其他数据。我选择一个并提交它。我希望将数据显示在另一个页面中,但它不会显示我所做的任何事情。

因此,有一个/form路由,我希望在上次提交之后,用我的数据在/confirmation路由上重定向。

Bellow是我在angularjs的formController

代码语言:javascript
复制
.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路由

代码语言:javascript
复制
    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是怎么回事

代码语言:javascript
复制
 <pre>
    {{otherResponse | json}}
</pre>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-03-21 12:28:28

您没有传递“值”,您需要这样做:

$location.path(‘/确认/’).search({param:'otherResponse'});

$location方法是可链接的。

这种产品:

/确认/?param=其他答复

检查文档中的$location

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36130703

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档