• Skip to main content
  • Skip to primary sidebar

Web Development Archive

  • Archive
You are here: Home / Angular / Hide something on specific route

Hide something on specific route

V1

private readonly _router = inject(Router);

private readonly _hiddenMastersRoutes = [
'/example-url-1',
'/example-url-2',
'/example-url-3',
] as const;

readonly displayMasters = computed(() => {
const url = this._router.url;

return !this._hiddenMastersRoutes.some((route) => url.includes(route));
});

V2

import { ChangeDetectionStrategy, Component, computed, inject } from '@angular/core';
import { Router } from '@angular/router';

@Component({
selector: 'app-sidebar',
templateUrl: './sidebar.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class Sidebar {
private readonly _router = inject(Router);

readonly displayMasters = computed(() => {
const url = this._router.url;

return (
!url.includes('/example-url-1') &&
!url.includes('/example-url-2')
);
});
}
@if (displayMasters()) {
<app-masters />
}

Filed Under: Angular

About Gabor Flamich

I'm a web developer and designer based in Budapest, Hungary. In recent years, I've documented hundreds of solutions I came across during development. This site is an archive for useful code snippets on WordPress, Genesis Framework and WooCommerce. If You have any questions related to WordPress development, get in touch!

Primary Sidebar

  • angular.io
© 2026 WP Flames - All Right Reserved