Answer the question
In order to leave comments, you need to log in
Angular route - how to check which page I'm on?
Hello.
In Angular route I have a page defined like this:
{ path: "support/:id", component: SupportViewComponent }
public RegExpSearchNum = new RegExp(/\d/);
constructor(public route: Router) {}
<p>{{ route.url.search(RegExpSearchNum) != -1 && route.url.search('/support/') != -1 ? true : false }}</p>
Answer the question
In order to leave comments, you need to log in
Can do
this.route.events.pipe(
map(() => this.route.currentUrlTree.root.children.primary.segments[1].path), // вместо 1 посмотреть ваш индекс
distinctUntilChanged(), // или можно ловить только NavigationEnd
map(path=> path === 'support')
)
this.route.routerState.snapshot.url
and contains a stream with the current navigation. Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question