I've been trying to get a button to work to bring up a page, passing an object in the parameters, but for some reason, it gives me the error
我一直试着让一个按钮来打开一个页面,在参数中传递一个对象,但是出于某种原因,它给了我错误。
"co. is not a function."
“公司不是一个功能。”
I don't know what the problem is because it gives me the same error when I try to use alert
or console.log
, or anything.
我不知道问题是什么,因为当我试图使用警告或控制台时,它给了我同样的错误。日志,或任何东西。
page HTML:
HTML页:
<ion-header>
<ion-navbar>
<ion-title>SearchResults</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<ion-list>
<ion-item *ngFor= "let item of resultArray;">
<img src={{item.thumbnail}} />
<p>{{item.title}}</p>
<button bookDetail (click)="console.log(\"Even some text, please?\")">DETAIL</button>
</ion-item>
</ion-list>
</ion-content>
1 个解决方案
#1
8
On your ts
file just do like below.
在你的ts文件中,如下所示。
.ts
.ts
log():void {
console.log('Your message here');
}
html
html
<button ion-button (click)="log()">DETAIL</button>
Note: If you need to pass the item
then just do like this log(item)
on html
side and ts
side log(data):void {}
.
注意:如果需要传递项目,那么只需在html端执行此日志(项目),并在ts端日志(数据):void{}。
#1
8
On your ts
file just do like below.
在你的ts文件中,如下所示。
.ts
.ts
log():void {
console.log('Your message here');
}
html
html
<button ion-button (click)="log()">DETAIL</button>
Note: If you need to pass the item
then just do like this log(item)
on html
side and ts
side log(data):void {}
.
注意:如果需要传递项目,那么只需在html端执行此日志(项目),并在ts端日志(数据):void{}。