diff --git a/src/app/app.component.html b/src/app/app.component.html index a85ba427d3695e6f308c1be2bbd9d7b403e29fc7..1f213cb1f853737c178561385e2d7429252978c8 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -3,8 +3,7 @@ </mat-toolbar> <nav mat-tab-nav-bar mat-stretch-tabs> <a mat-tab-link *ngFor="let link of links; index as i" - [href]="link" - (click)="activeLink = link" - [active]="activeLink == link"> {{titles[i]}} </a> -</nav> + [href]="link" + [active]="activeLink == link"> {{titles[i]}} </a> +</nav> <router-outlet></router-outlet> \ No newline at end of file diff --git a/src/app/app.component.ts b/src/app/app.component.ts index cd620f70f0e3556f8bf323dc4ebe000871e1da27..4cbc33e5c754c0913cfd5bdfdcc6221177ebdc2f 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,13 +1,23 @@ import { Component } from '@angular/core'; - +import { Router, ActivatedRoute } from '@angular/router'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.scss'] }) export class AppComponent { + constructor(public router: Router, public route: ActivatedRoute) {} + + activeLink = ""; links = ['#/bestand', '#/buchung', '#/neu']; titles = ['Bestand', 'Buchung', 'Neu']; - activeLink = this.links[1]; title = 'Lagerverwaltung'; + ngOnInit(){ + console.log(this.router.url); + this.router.events.subscribe((url:any) => { + if(url.url != undefined) { + this.activeLink = "#" + url.url + } + }); + } }