2
각도 (2+) 라우터에는 rxjs 제목 인 events 속성이 있습니다. 일단 가입 각도 라우터 이벤트 이름
, 당신은 같은 이벤트를 수신 할 수 있습니다 :router.events.subscribe((event: Event) => { console.log(event) });
하지만 문제는 당신이 모든 이벤트를 수신하기 때문에 이벤트 유형을 얻을 수있는 방법이 없습니다. 이 작업을 수행 할 수있는 더 좋은 방법이 있다면 내가 궁금
router.events.subscribe((event: Event) => {
if(event.constructor.name === 'NavigationStart') {
loadingService.start();
} else if(event.constructor.name === 'NavigationEnd') {
loadingService.complete();
drawerService.destroyAll();
}
});
: 해키 솔루션은이 같은 이벤트의 생성자의 이름을 검사 할 수있다?
감사를 참조하십시오! 문서를 다시 PR'd! https://github.com/angular/angular/pull/15142 – amcdnl
가장 좋은 형태의 공헌 : –