如何使用ASP.NET Core Angular SPA模板实现对内容更改的加载微调器?
问题描述:
我刚刚建立,以创建用于测试目的的SPA基于对ASP.NET 2.0核心的角模板玩具项目:如何使用ASP.NET Core Angular SPA模板实现对内容更改的加载微调器?
- https://github.com/aspnet/JavaScriptServices/tree/dev/templates/AngularSpa
- https://blogs.msdn.microsoft.com/webdev/2017/02/14/building-single-page-applications-on-asp-net-core-with-javascriptservices/
我知道,服务器预渲染过程对于SPA来说已经让事情变得更快,但只是在延迟的情况下。
但仍然如何实现这一目标?它可以实际上完全自动化(如适用于在客户端编码的所有视图(!*。cshtml))吗?
感谢
答
如果你想在路线变化的微调,你可以设置一个标志作为路由器事件的一部分:
checkRouterEvent(routerEvent: Event): void {
if (routerEvent instanceof NavigationStart) {
this.loading = true;
}
if (routerEvent instanceof NavigationEnd ||
routerEvent instanceof NavigationCancel ||
routerEvent instanceof NavigationError) {
this.loading = false;
}
}
然后打开/关闭根据该标志的好手。
在HTML:
<span class="glyphicon glyphicon-refresh glyphicon-spin spinner" *ngIf="loading"></span>
我已经工作的例子在这里设置:https://github.com/DeborahK/Angular-Routing(在APM-最终文件夹)。
+0
谢谢!这正是我期待的!感觉哑巴=。/ 真的需要观看你的视频=] – Ehouarn
可能重复的[Angular HttpClient - 显示微调器/进度指示器,而等待服务响应 - 进度事件](https://stackoverflow.com/questions/45512285/angular-httpclient-show-spinner-progress-indicator- while-waiting-for-service-t) – Aravind
@Aravind hm也许让我检查一下 – Ehouarn