Issue
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.
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'"
is not working. Any alternatives?
Solution
mycomponent.component.ts
import { Router } from '@angular/router'
class MyComponent {
constructor(public router: Router) { }
}
mycomponent.component.html
<div *ngIf="router.url === '/some/route'">
<!-- … -->
</div>
Answered By - Arvind Audacious
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.