angular – 如何捕获* ngIf中的路线

前端之家收集整理的这篇文章主要介绍了angular – 如何捕获* ngIf中的路线前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
因此,我想在特定页面被击中时使我的Header上的锚元素消失.当该页面被击中时,如何在* ngIf中捕获url.

我有一个标题,所有页面都保持相同.当我在/ home路由时,只需要隐藏一个锚元素.如何在* ngIf中捕获这个“/ home”?

* ngIf =“href =’/ home’”无效.任何替代品?

  1. //mycomponent.component.ts
  2. class MyComponent {
  3. constructor(private router: Router){
  4.  
  5. }
  6. }
  7.  
  8. //mycomponent.component.html
  9. <div *ngIf="router.url === '/some/route'">
  10.  
  11. </div>

猜你在找的Angularjs相关文章