Created
August 22, 2017 18:33
-
-
Save willgm/c0ac94c13df40ed9d157016a1b8b5289 to your computer and use it in GitHub Desktop.
Spinner no carregamento de uma rota no Angular 2+
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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