How to *ngIf on router link?

后端 未结 3 1276
小鲜肉
小鲜肉 2021-02-01 16:01

I need to show some content on certain page, in other pages it shouldn\'t be visible. How do I achieve it ? it doesn\'t work

*ngIf=\"[routerLink]=\"[\'/home\']\"<

3条回答
  •  滥情空心
    2021-02-01 16:29

    If your routes are well defined you can try this:

    isTournamentRoute() {
        return this.router.url.includes("/tournament");
    }
    

    Which is piggybacking off the non accepted answer to add a bit more flexibility.

提交回复
热议问题