zoukankan      html  css  js  c++  java
  • angualr $http 页面传参问题

    POST 请求传参

    $http({

      method: "POST",
    url: url,
    data: {
    "role_id": 1,
    "telephone": $scope.setData.telephone,
    "user_pwd": $scope.setData.user_pwd
    },
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    transformRequest: function(obj) {
    var str = [];
    for (var s in obj) {
    str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));
    }
    return str.join("&");
    }
    }).then(function (res) {});

    GET请求传参
     $http({
                    method: "get",
                    params:{id:1,name:jyy},
                    url:"1.php"
                })

    http://blog.csdn.net/gufeilong/article/details/53584967
    页面传参
    传递单个参数
    要在目标页面定义接受的参数:
    .state("project-complaint",{
    url:'/project-complaint',
    params:{"id":null},
    views: {
    'main': {
    templateUrl: 'view/project-complaint.html',
    controller: 'project-complaintCtrl'
    }
    },
    cache:false
    })
    //工程投诉
    $scope.complaint = function (item) {
    $state.go("project-complaint", {id: item.order_number});
    };
    接收参数
    console.log( $stateParams.id)


    传递对象
    .state("project-complaint",{
    url:'/project-complaint/:object',
    views: {
    'main': {
    templateUrl: 'view/project-complaint.html',
    controller: 'project-complaintCtrl'
    }
    },
    cache:false
    })
     $state.go("app.example2", {object: JSON.stringify(obj)});

    接收参数
     console.log(JSON.parse($state.params.object));
    http://blog.csdn.net/qq_dai/article/details/52869866
  • 相关阅读:
    主席树学习记录
    P1072 Hanson 的趣味题 题解
    好文章收集
    计算几何专题
    小问题
    CSP-S2020题解
    上下界网络流
    想到的无法解决的点子
    省选联考2020组合数问题
    省选数学复习
  • 原文地址:https://www.cnblogs.com/xyc211/p/7452676.html
Copyright © 2011-2022 走看看