0
嗨我想獲得JSON數據庫只在我點擊的項目上,當我點擊該項目時,我沒有得到任何JSON數據,而是說它的'undefined'在控制檯。希望你能幫助我。這裏是我的代碼:獲取JSON數據的基礎上,我點擊離子2
Featured.ts
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { TestProviderPage } from '../testprovider/testprovider';
import { ProductPage } from '../product/product';
@Component({
selector: 'page-featured',
templateUrl: 'featured.html',
providers: [TestProviderPage]
})
export class FeaturedPage {
products: any;
constructor(public navCtrl: NavController, public testProvider: TestProviderPage) {
this.loadItems();
}
goToProductPage(item){
this.navCtrl.push(ProductPage, { item: item });
}
loadItems(){
this.testProvider.loadpatrick().then(data => {
this.products = data;
console.log(this.products);
});
}
}
product.ts
import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import { MorePage } from '../more/more';
@Component({
selector: 'page-product',
templateUrl: 'product.html'
})
export class ProductPage {
item: any;
tabBarElement: any;
constructor(public navCtrl: NavController, public navParams: NavParams) {
this.tabBarElement = document.querySelector('.tabbar.show-tabbar');
this.item = this.navParams.get('product');
console.log(this.item);
}
}