我有一个奇怪的问题,Angular 2 ngIf语句只在页面上显示一秒钟然后消失。这是因为我看到它,但它不想留在页面上。猜测这是某种奇怪的同步事物。下面的代码:Angular 2 ngIf只显示一秒
<div class="holder">
<h2 *ngIf="!this.userHomeService.cards">
You haven't created any cards.
</h2>
<div class="card-div"
*ngFor="let c of this.userHomeService.cards">
<h3 (click)="onSelect(c)">{{c.title}}</h3>
</div>
了'ngIf'没有停止下一条语句中,'ngFor',被显示。你看到来自'ngFor'语句关于'this.userHomeService.cards'为'undefined'的控制台错误吗? – Claies
它看起来好像没有显示出来。如果我添加一张卡,那么会出现,否则没有任何内容。我没有得到任何控制台错误 – Linx