简体   繁体   English

在Angular2中注入大量HTML期间的微调

[英]Spinner in Angular2 during injecting large part of html

In my Angular application I have a switch that causes injecting large html data into the page. 在我的Angular应用程序中,我有一个开关,导致将大量html数据注入到页面中。 It takes about 1-2 seconds to inject and I wonder if it is posssible to implement a spinner, to let know to user that a view is rendering. 注入大约需要1-2秒,我想知道是否有可能实现微调器,以告知用户视图正在渲染。

I saw few implementations based on typescript code but none fits to my case. 我看到很少有基于打字稿代码的实现,但是都不适合我的情况。 I'd like to do it only in view - if possible. 我只想在可能的情况下这样做。

<table (click)="switch.active=!switch.active">
<tr *ngFor="condition"></tr> //here I have about 500 rows
</table>

You can use ng-show or ng-hide to get the desire effect. 您可以使用ng-show或ng-hide获得效果。 Set the condition to true based on when the loading of your data is done through js part. 根据通过js部件完成数据加载的时间,将条件设置为true。 I don't know how you are fetching the data but you can put a condition there to see when it is done then update the ng-show condition, till data id loading show a spinner. 我不知道您如何获取数据,但是可以在此处放置一个条件以查看何时完成,然后更新ng-show条件,直到数据id加载显示微调框为止。

You can also try to put loader for each row so for user can see the data even it is not fully loaded. 您还可以尝试为每行放置加载程序,以便用户即使未完全加载数据也可以看到数据。

    <table (click)="switch.active=!switch.active">
    <div class="spinner" ng-show="true condition till data is loading">
    </div>
    <tr *ngFor="condition" ng-show="(negate false) condition when loading complete"></tr>
    </table>

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

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