![](/img/trans.png)
[英]How to allow my Product1 users to bookmark my Product2 link from Product1 web page?
[英]Undefined object from my product page
这是我到product-details.ts的构造函数
product: any; constructor(public navCtrl: NavController, public navParams: NavParams) { this.product = this.navParams.get("product"); console.log(this.product); }
这是我的家
openProductPage(product){ this.navCtrl.push(ProductDetailsPage, {"product": product} ); }
这是html文件home.html
<ion-list> <ion-item *ngFor="let products of moreProducts" text-wrap (click)="openProductPage(product)"> <ion-thumbnail item-left> <img [src]="products.featured_src" /> </ion-thumbnail> <h1>{{products.title}}</h1> <p> <span [innerHTML]="products.short_description.substr(0, 50) + '...'"></span> <span [innerHTML]="products.price_html"></span> </p> <button ion-button icon clear item-right> <ion-icon name="arrow-forward"></ion-icon> </button> </ion-item> </ion-list>
当我单击产品时,通过在app.module.ts中添加所有必需的东西的方式在控制台日志中显示“ undefined”,这些东西会导入“ ...”,声明和entryComponents
在您的代码中,您正在使用ngFor
products
,因此在调用click方法时应使用该变量。
<ion-item *ngFor="let products of moreProducts" text-wrap (click)="openProductPage(products)">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.