首页 > 其他 > 详细

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

时间:2017-06-14 23:58:55      阅读:1775      评论:0      收藏:0      [点我收藏+]

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

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

(0)
(1)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!