【问题标题】:$http.get with 2 parameter in ionic framework (angularjs)$http.get 在 ionic 框架(angularjs)中有 2 个参数
【发布时间】:2015-06-08 21:13:02
【问题描述】:

我的 $http.get 有一个参数,它的工作原理如下:

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

我想发送 2 个参数,例如:

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

$http.get字段中如何调用email和param2?

【问题讨论】:

    标签: angularjs ionic-framework ionic


    【解决方案1】:

    您可以使用 '&' 附加参数:

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

    【讨论】:

      【解决方案2】:

      将所有 url 参数存储在一个对象中,例如,

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

      现在使用以下代码发出请求,

      $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 
      })
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-09-12
        • 2016-07-16
        • 2018-05-29
        • 1970-01-01
        • 2016-11-23
        • 2016-05-30
        • 2017-09-28
        相关资源
        最近更新 更多