简要说明:我需要console.log(i.match)
列表中点击的项目。请参阅我的**home.html**
代码。这就是创建列表的方式
home.html
<ion-card>
<ion-card-content *ngFor="let match of matches ; let i = index">
<p (click)="spch(i)">{{ match }}</p>
</ion-card-content>
</ion-card>
以及home.ts
listen(): void {
console.log('listen action triggered');
if (this.isListening) {
this.speech.stopListening();
this.toggleListenMode();
return;
}
this.toggleListenMode();
let _this = this;
this.speech.startListening()
.subscribe(matches => {
_this.zone.run(() => {
_this.matches = matches;
})
}, error => console.error(error));
}
toggleListenMode():void {
this.isListening = this.isListening ? false : true;
console.log('listening mode is now : ' + this.isListening);
}
spch(i)
{
alert('speech');
alert(i.match);
alert(i.matches);
alert(i);
console.log('speech');
console.log(i.match);
}
alert(i.match)
未定义,alert(i.matches)
也未定义,alert(i)
显示索引号,但我没有获得点击项目的价值。
答案 0 :(得分:2)
你这样做是错误的。你已经将i声明为索引,它只包含索引值。 尝试传递两个参数:
SELECT MONTHS,
SUM(CASE WHEN A.TYPE = 'A' AND A.NEW = 'Y' THEN 1 ELSE 0 END) AS A_NEW,
SUM(CASE WHEN A.TYPE = 'A' AND A.OLD = 'Y' THEN 1 ELSE 0 END) AS A_OLD,
SUM(CASE WHEN A.TYPE = 'B' AND A.NEW = 'Y' THEN 1 ELSE 0 END) AS B_NEW,
SUM(CASE WHEN A.TYPE = 'B' AND A.OLD = 'Y' THEN 1 ELSE 0 END) AS B_OLD,
SUM(CASE WHEN A.TYPE = 'C' AND A.NEW = 'Y' THEN 1 ELSE 0 END) AS C_NEW,
SUM(CASE WHEN A.TYPE = 'C' AND A.OLD = 'Y' THEN 1 ELSE 0 END) AS C_OLD,
SUM(CASE WHEN A.TYPE = 'D' AND A.NEW = 'Y' THEN 1 ELSE 0 END) AS D_NEW,
SUM(CASE WHEN A.TYPE = 'D' AND A.OLD = 'Y' THEN 1 ELSE 0 END) AS D_OLD
FROM
MYTABLE A
GROUP BY MONTHS;
并且在ts:
{{1}}