简体   繁体   English

加载屏幕上的角度变化ngIf

[英]Angular change ngIf on loading screen

on my view screen, my page will look like this 在我的视图屏幕上,我的页面将如下所示

在此输入图像描述

for the download button, I'm using jspdf to generate a pdf file but it will generate something like this 对于下载按钮,我使用jspdf生成pdf文件,但它会生成这样的东西

在此输入图像描述

And this is one of my example of the input box 这是我输入框的一个例子

<div class="col-md-2">
    <label for="name">Name :</label>
</div>
<div class="col-md-6">
    <input mdbInputDirective [mdbValidate]="false" type="text" class="form-control" style="border:1px solid;"
    formControlName="address1" disabled>
</div>

How can i make when the user press the download button it will show a loading button (that I will make myself) and the content of the page will change into something like a table or something else and the pdf that has been downloaded will show the table instead of showing the input box and after the loading screen is finish then it will turn back into the normal page. 当用户按下下载按钮时,我将如何显示它将显示一个加载按钮(我将自己创建),并且页面的内容将变为类似于桌子或其他内容的内容,并且已下载的pdf将显示表而不是显示输入框,并在加载屏幕完成后,它将返回到正常页面。

A common practice to place a loader on Angular apps is the following. 将加载程序放在Angular应用程序上的常见做法如下。

TS TS

public loading: boolean = false;

public doDownload(): void {
    // Start downloading
    this.loading = true;
    // Do your work
    this.loading = false;
}

HTML HTML

<div *ngIf="loading">Loader</div>
<div *ngIf="!loading">Content</div>

Instead of a Loading message, you could use a loader SVG or https://github.com/airbnb/lottie-web 您可以使用加载程序SVG或https://github.com/airbnb/lottie-web而不是加载消息

Also, make sure your change detector is automatically re-rendering the DOM. 此外,请确保您的更改检测器自动重新呈现DOM。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM