[Angular] How to show global loading spinner for application between page navigation
app.component.ts:
import { Component, OnInit } from "@angular/core";
import { select, Store } from "@ngrx/store";
import { Observable } from "rxjs";
import { map } from "rxjs/operators";
import {
NavigationCancel,
NavigationEnd,
NavigationError,
NavigationStart,
Router
} from "@angular/router";
import { AppState } from "./reducers/index";
import { isLoggedIn, isLoggedOut } from "./auth/auth.selectors";
import { AuthActions } from "./auth/action-types";
@Component({
selector: "app-root",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.css"]
})
export class AppComponent implements OnInit {
loading = true;
constructor(private store: Store<AppState>, private router: Router) {}
ngOnInit() {
...this.router.events.subscribe(event => {
switch (true) {
case event instanceof NavigationStart: {
this.loading = true;
break;
}
case event instanceof NavigationEnd:
case event instanceof NavigationCancel:
case event instanceof NavigationError: {
this.loading = false;
break;
}
default: {
break;
}
}
});
}
}
<div class="spinner-container" *ngIf="loading">
<mat-spinner></mat-spinner>
</div>
[Angular] How to show global loading spinner for application between page navigation的更多相关文章
- 加载旋转框(loading spinner)
目标是这样的 用到的组件 AlertDialog 和 ProgressBar 先创建一个 AlertDialog 的布局 <?xml version="1.0" encodi ...
- Angular 2 to Angular 4 with Angular Material UI Components
Download Source - 955.2 KB Content Part 1: Angular2 Setup in Visual Studio 2017, Basic CRUD applicat ...
- Angular源代码学习笔记-原创
时间:2014年12月15日 14:15:10 /** * @license AngularJS v1.3.0-beta.15 * (c) 2010-2014 Google, Inc. http:// ...
- 升级 AngularJS 至 Angular
Victor Savkin 大神撰写了一系列文章详细介绍如何升级 AngularJS 应用: NgUpgrade in Depth Upgrade Shell Two Approaches to Up ...
- Ionic4.x Javascript 扩展 ActionSheet Alert Toast Loading 以及 ionic 手势相 关事件
1.ActionSheet 官方文档:https://ionicframework.com/docs/api/action-sheet <ion-header> <ion-toolb ...
- Angular概念纵览
Conceptual Overview Template(模板): HTML with additional markup (就是增加了新的标记的HTML) Directive(指令): extend ...
- (七)理解angular中的module和injector,即依赖注入
(七)理解angular中的module和injector,即依赖注入 时间:2014-10-10 01:16:54 阅读:63060 评论:1 收藏:0 [点 ...
- Angular JS中的依赖注入
依赖注入DI angularjs中与DI相关有angular.module().angular.injector(). $injector.$provide. DI 容器3要素:服务的注册.依赖关系的 ...
- 随机Loading
using UnityEngine; using System.Collections; public class Loading : MonoBehaviour { public bool m_Is ...
随机推荐
- spring boot 初始
前言 与时俱进是每一个程序员都应该有的意识,当一个Java程序员在当代步遍布的时候,你就行该想到我能多学点什么.可观的是后端的框架是稳定的,它们能够维持更久的时间在应用中,而不用担心技术的更新换代.但 ...
- 升级nginx1.12为1.161版本
升级nginx1.12为1.161版本 一.添加源 到 cd /etc/yum.repos.d/ 目录下 新建nginx.repo 文件 vim nginx.repo 输入以下信息 [nginx-st ...
- python基础 — 致初学者的天梯
Python简介 Python是一种计算机程序设计语言.是一种面向对象的动态类型语言,最初被设计用于编写自动化脚本(shell),随着版本的不断更新和语言新 功能的添加,越来越多被用于独立的.大型项目 ...
- Spring MVC前端控制器不拦截静态资源配置
- net core quartz调度 warp打包 nssm部署到windowsservice
介绍下一款vue.js实现的基于core2.1 quartz.net调度框架,独立部署不依赖数据库,只需要实现不同业务接口,配置调度时间即可 github:https://github.com/cq- ...
- Linux进程间通信—使用共享内存
Linux进程间通信-使用共享内存 转自: https://blog.csdn.net/ljianhui/article/details/10253345 下面将讲解进程间通信的另一种方式,使用共享内 ...
- activiti串行会签的使用
1.串行任务的配置 2.当任务走到串行会签节点时,会从你之前保存的流程变量中找集合(我这里设置的assigneeList),串行会签会根据这个集合设置一系列该节点的流程变量 3.结束条件的设置,若满足 ...
- ADO.NET 四(DataReader)
DataReader 类概述 DataReader 类对应MSSQLSERVER在 System.Data.SqlClient 命名空间中,对应的类是 SqlDataReader,主要用于读取表中的查 ...
- 1-redis使用笔记
1.清空当前redis数据库缓存FLUSHDB flushdb 2.清空整个redis缓存FLUSHALL flushall 3.设置 SET w3ckey redis 4.获取 GET w3ckey ...
- @PropertySources和@ImportReSources注解
修改默认加载的配置文件,加载指定的配置文件. @PropertySources 格式:@PropertySources(value={"classpath:xxx.xxx"}) @ ...