从数据库获取时Angular2加载信息

Angular2 loading information when getting from database

我们都知道angular2可以这样显示"Loading"信息: <component-selector>Loading...</component-selector>

我们知道"Loading..."会在加载组件时隐藏

我的问题是,如何在其他情况下使用 "Loading..." 消息,例如:

<div *ngFor="let offer of offers | async">
  <p><strong>Title:</strong> {{offer?.title}}</p>
  <p><strong>Description:</strong> {{offer?.description}}</p>
  <hr>
</div>

我在构造函数中导入报价,但这些信息加载时间大约为 1-2 秒。我想显示一些 "Loading" 文本到它们显示的时间。有办法吗?

在 *ngFor 之前创建一个 *ngIf,如下所示:

<div *ngIf="!offers">Loading...</div>
<div *ngFor="let offer of offers | async">
  <p><strong>Title:</strong> {{offer?.title}}</p>
  <p><strong>Description:</strong> {{offer?.description}}</p>
  <hr>
</div>