如您所见,我有很多组件。
<app-main>
<app-title *ngIf="!(hideElement$ | async)"></app-title>
</app-main>
<app-title>
仅在路线与原点不同时显示
而我的控制者是
hideElement$: Observable<boolean> = this.router.events
.pipe(
filter((event) => event instanceof NavigationEnd),
map((data: any) => data.url === '/home')
);
constructor(
private breakpointsService: BreakpointsService,
private router: Router, private route: ActivatedRoute,
private location: Location) {
console.log(this.isHandset$);
}
如果我转回原位->另一个组件,app-title
不会重新加载数据,但是如果我刷新浏览器,它就可以工作。
请帮助我