child.snapshot.issue angular 我无法从激活的路由中获取数据

问题描述

你好,我有 2 个路由模块 app.routing 和 account.routing 我试图从路由中获取标题,但不适用于 account.routing 下的路由

  { path: 'mypath',loadChildren: () => import('./sap/sap.module').then(mod => mod.SApModule),data: { breadcrumb: 'SaP',title: 'TITLEs' } },
  const appTitle = this.titleService.getTitle();
  this.router
    .events.pipe(
      filter(event => event instanceof NavigationEnd),map(() => {
        const child = this.activatedRoute.firstChild;
        if (child.snapshot.data['title']) {
          return child.snapshot.data['title'];
        }
        return appTitle;
      })
    ).subscribe((ttl: string) => {
      this.titleService.setTitle(ttl);
    });

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)