$http.get with 2 parameter in ionic framework (angularjs)

风格不统一 提交于 2020-01-01 18:51:30

问题


I have my $http.get with one parameter, and it works like :

getUserBand: function(email) {
        return $http.get(baseUrl + 'selectUserBand.php?email=' + email);
    },

I want to send 2 parameter like :

getUserBand: function(email,param2) {
        How to call 2 parameter in this field?
    },

How to call email and param2 in the $http.get field?


回答1:


You can append param with '&':

getUserBand: function(email,param2) {    
  $http.get(baseUrl + 'selectUserBand.php?email=' + email + '&param2=' + param2);
}



回答2:


Store all your url params in an object like,

var urlParams = {
    'param1': email,
    'param2': username
},

now make the request using the following code,

$http({
    method: 'GET',
    url: 'url from which you want to get',
    params: urlParams //which will be automatically turned to ?key1=value1&key2=value2 after the url 
})


来源:https://stackoverflow.com/questions/30709772/http-get-with-2-parameter-in-ionic-framework-angularjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!