一旦来自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>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句