2017-05-27 119 views
0

我有一些屏幕,我將在這裏調用一些URL。但我知道如何使用獲取並顯示數據來調用該函數。但是現在我想用url發送參數。如何將參數傳遞給url

這裏我url.i需要發送的參數:

this.passingdata = { CatID: "2" }; 

這上面的參數我需要發送到以下網址獲取功能

constructor(public viewCtrl: ViewController, public modalCtrl: ModalController, private http: Http, public loadingCtrl: LoadingController) { 
    let that = this 
    let loader = this.loadingCtrl.create({ 
     content: "Please wait..." 
    }); 
    loader.present(); 
    that.http.get('http://www.example.com/api/tackj.php').map((res) => res.json()).subscribe((data: any) =>{ 
     that.questions = data.QuestionsList; 
     loader.dismiss(); 
    }) 
    } 

    ionViewDidLoad() { 
    let that = this; 
    that.slides.lockSwipes(true); 
    that.slides.enableKeyboardControl(false); 
    } 

預先感謝!

回答

0

如果你想傳遞一些參數最有可能它是一個post方法,那麼你可以將數據作爲第二個參數傳遞給http.post方法。所以你需要找出API是post方法還是get方法。 請參閱這個鏈接 AngularJS passing data to $http.get request

+0

OKAY,與我相同的代碼告訴我,我怎麼可以通過paremeter ....我們可以改變這個值'post'而不是'get' –