Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ionic framework 在ionic 3中传递api的参数_Ionic Framework_Ionic3 - Fatal编程技术网

Ionic framework 在ionic 3中传递api的参数

Ionic framework 在ionic 3中传递api的参数,ionic-framework,ionic3,Ionic Framework,Ionic3,我是新来的离子和试图通过api从供应商的应用程序的ts页面,但我得到了一个错误,也许我传递了错误的id TS部分: export class CardsPage { currentItems: Item[]; id: any; getData: Object; categories; constructor(public navCtrl: NavController, public api:Api, navParams: NavParams,

我是新来的离子和试图通过api从供应商的应用程序的ts页面,但我得到了一个错误,也许我传递了错误的id

TS部分:

 export class CardsPage {
    currentItems: Item[];
    id: any;
    getData: Object;
    categories;
 constructor(public navCtrl: NavController, public api:Api, navParams: 
       NavParams, items: Items, public http: HttpClient) {
             this.id = navParams.get('idName') ||'';
             console.log(this.id); 
 this.api.getCategoryPosts(this.id).subscribe(data=>{
   console.log(data)
   this.getData = data
},err=>{
     console.log(err)
 })
 }
    openItem(item){
    this.navCtrl.push('ItemDetailPage', {
    itemName: item
  });
}
}

Api:


我已经发布了关于API和ts文件的代码部分,现在我想使用参数将数据传递到下一页。我想知道我应该传递什么参数来获取下一页中显示的数据根据您的代码,您正在将id直接传递给服务的
getCategoryPosts
方法。因此,请使用
category
而不是下面的
category.id

getCategoryPosts(category: any) {
      return this.http.get(`${this.api_url}/posts?categories=${category}`);
  }

请发布错误的副本。引用错误:未定义类别引用错误。在新卡上未定义类别SPAGEI仍然收到此错误:-引用错误:未定义类别引用错误。新卡片页未定义类别。
getCategoryPosts(category: any) {
      return this.http.get(`${this.api_url}/posts?categories=${category}`);
  }