Skip to content

Instantly share code, notes, and snippets.

@willgm
Created August 22, 2017 18:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save willgm/c0ac94c13df40ed9d157016a1b8b5289 to your computer and use it in GitHub Desktop.
Save willgm/c0ac94c13df40ed9d157016a1b8b5289 to your computer and use it in GitHub Desktop.
Spinner no carregamento de uma rota no Angular 2+
import { Component } from '@angular/core';
import { Router, NavigationStart, NavigationEnd } from '@angular/router';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['../assets/styles/index.sass'],
})
export class AppComponent {
constructor(
private router: Router,
) {
this.router.events.subscribe(event => {
if (event instanceof NavigationStart) {
console.log('iniciar spinner');
}
if (event instanceof NavigationEnd) {
console.log('finalizar spinner');
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment