分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 软件开发

angualr $http ??页面传参问题

发布时间:2023-09-06 01:07责任编辑:胡小海关键词: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

angualr $http ??页面传参问题

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

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved