[英]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.