[英]Angular2 - Show a loading message, and hide it once the async call finishes
一旦来自REST API的异步调用完成后,我愿意显示/隐藏“ 正在加载”消息 ,它会隐藏“ 正在加载”消息并显示取回的内容。
我不知道如何在Angular2中实现这一目标,但是在JavaScript中,是这样完成的:
<h2 id="message">Loading....</h2>
<script>
$(document).ready(function(){
$('#message').hide();
//Then Show the newly fetched content
}
</script>
我相信您正在使用ngFor来显示获取的数据。
这应该为您工作:
<div *ngIf="!content">Loading...</div>
<div #ngFor="#content of content"></div>
<div *ngIf="content">Now the fetched content appears here!</div>
<div *ngIf="!content">Loading...</div>
<div *ngIf="content"> TODO display the content here </div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.