首页 > Web开发 > 详细

angualr $http 页面传参问题

时间:2017-08-30 14:06:34      阅读:366      评论:0      收藏:0      [点我收藏+]

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

angualr $http 页面传参问题

原文:http://www.cnblogs.com/xyc211/p/7452676.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!