如何在* ngIf中捕捉路线 [英] How to catch routes in *ngIf
本文介绍了如何在* ngIf中捕捉路线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
因此,我想使标题上的锚点元素在点击特定页面时消失.当该页面被点击时,如何捕获* ngIf中的网址.
So I want to make an anchor element on my Header disappear when a specific page is hit. How can I catch the url in the *ngIf when that page is hit.
我有一个标题,所有页面都将保持不变.当我在/home进行路由时,只需要隐藏一个锚元素即可.如何在* ngIf中捕获此"/home"?
I have a header which will remain same for all pages. Just need to hide an anchor element when I am routed at /home. How to catch this "/home" in *ngIf?
* ngIf ="href ='/home'"无法正常工作.有其他选择吗?
*ngIf = "href='/home'" is not working. Any alternatives?
推荐答案
//mycomponent.component.ts
class MyComponent {
constructor(private router: Router){
}
}
//mycomponent.component.html
<div *ngIf="router.url === '/some/route'">
</div>
这篇关于如何在* ngIf中捕捉路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文