navbar dynamique

pull/2/head
Maxence JOUANNET 5 months ago
parent d7dc8f5e39
commit d24171607b

@ -1,23 +1,24 @@
import { Component, OnInit } from '@angular/core';
import { NgIf } from '@angular/common';
import { Router, NavigationEnd } from '@angular/router';
@Component({
selector: 'app-navbar',
imports: [NgIf],
templateUrl: './navbar.component.html',
})
export class NavbarComponent {
export class NavbarComponent implements OnInit {
isHomePage: boolean = false;
constructor() {
}
constructor(private router: Router) {}
ngOnInit(): void {
let url = window.location.pathname;
if (url === '/') {
this.isHomePage = true;
}
this.isHomePage = this.router.url === '/';
this.router.events.subscribe((event) => {
if (event instanceof NavigationEnd) {
this.isHomePage = event.url === '/';
}
});
}
}

Loading…
Cancel
Save