*ngIf 用于所有子路由

*ngIf for all sub routes

我想弄清楚如何为所有子路由显示带有 *ngIf 的容器。

赞:

<div *ngIf="router.url === /page/**"></div>

所以当我在 "page" 以及 "page" 的所有子页面时都会显示此容器。

感谢您的帮助

    public currentLink: string;

    constructor(private router: Router){

        this.currentLink = this.router.url;

   }
   if(this.currentLink.startsWith('/page/')) this.flag = true;
   else this.flag = false;

  <div *ngIf="flag"></div>

> you can get the URL using observable also