码迷,mamicode.com
首页 > 其他好文 > 详细

[Angular] Show a loading indicator in Angular using *ngIf/else, the as keyword and the async pipe

时间:2017-06-15 00:41:47      阅读:183      评论:0      收藏:0      [点我收藏+]

标签:pos   click   his   loading   ...   network   using   rect   use   

The network may be unreliable and loading data may take time. Thus it is important to give the user some feedback about what‘s going on as fast as possible. In this lesson we learn how to leverage the else block of the *ngIf directive to show a simple loading indicator.

 

    <div *ngIf="buttonClicked">
      <div *ngIf="person$ | async as person; else personLoading">
        Name: {{ person.name }} <br />
        Twitter: {{ person.twitter }}
      </div>
      <ng-template #personLoading>
        Loading person...
      </ng-template>
    </div>

 

[Angular] Show a loading indicator in Angular using *ngIf/else, the as keyword and the async pipe

标签:pos   click   his   loading   ...   network   using   rect   use   

原文地址:http://www.cnblogs.com/Answer1215/p/7011520.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!