【发布时间】:2018-03-28 18:11:40
【问题描述】:
我想查看离子卡的元素引用,但看不到。下面是我的代码。
.html
<ion-content>
<ion-card *ngFor="let card of cards" #card>
</ion-card>
</ion-content>
.ts
//all imports are made
//class defined
@ViewChild("card", {read: ElementRef}) card: ElementRef;
constructor(private elementRef: ElementRef){}
ngAfterViewInit(): void {
console.log('card' -->, this.card); // in the console it displays undefined
}
【问题讨论】:
-
你应该尝试
@ViewChildren而不是@ViewChild。
标签: angular ionic-framework ionic2 ionic3 viewchild