can now switch championships

This commit is contained in:
Joachim 2018-09-01 15:51:40 +02:00
parent 0f1434bb25
commit 19aa6f3a4c
2 changed files with 9 additions and 2 deletions

View File

@ -1,3 +1,3 @@
<mat-list> <mat-list>
<mat-list-item *ngFor="let championship of championships()"> {{championship.name}} </mat-list-item> <mat-list-item (click)="selectChampionship(championship)" *ngFor="let championship of championships()"> {{championship.name}} </mat-list-item>
</mat-list> </mat-list>

View File

@ -1,6 +1,7 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import {MatDialogRef} from '@angular/material'; import {MatDialogRef} from '@angular/material';
import {ChampionshipService} from '../championship.service'; import {ChampionshipService} from '../championship.service';
import {Router} from '@angular/router';
@Component({ @Component({
selector: 'app-championshipselectordialog', selector: 'app-championshipselectordialog',
@ -10,7 +11,8 @@ import {ChampionshipService} from '../championship.service';
export class ChampionshipselectordialogComponent implements OnInit { export class ChampionshipselectordialogComponent implements OnInit {
constructor(public dialogRef: MatDialogRef<ChampionshipselectordialogComponent>, constructor(public dialogRef: MatDialogRef<ChampionshipselectordialogComponent>,
private championshipService: ChampionshipService) { } private championshipService: ChampionshipService,
private router: Router) { }
ngOnInit() { ngOnInit() {
@ -20,4 +22,9 @@ export class ChampionshipselectordialogComponent implements OnInit {
return this.championshipService.getChampionships(); return this.championshipService.getChampionships();
} }
selectChampionship(championship: any) {
this.championshipService.setChampionship(championship.idchampionship);
this.router.navigate(['championship', championship.idchampionship]);
this.dialogRef.close();
}
} }