angualr $http 頁面傳參問題

來源:互聯網
上載者:User

標籤:var   cat   urlencode   use   enc   view   data   als   return   

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 頁面傳參問題

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.