got championships load and current champ working
This commit is contained in:
parent
0759e7b484
commit
310e1ccd2d
21
src/app/app-routing.module.ts
Normal file
21
src/app/app-routing.module.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import {NgModule} from '@angular/core';
|
||||||
|
import {CommonModule} from '@angular/common';
|
||||||
|
import {RouterModule, Routes} from '@angular/router';
|
||||||
|
import {TierComponent} from './content/tier/tier.component';
|
||||||
|
|
||||||
|
const routes: Routes = [
|
||||||
|
{path: 'championship/:idchampionship/tier/:idtier', component: TierComponent},
|
||||||
|
];
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [
|
||||||
|
CommonModule,
|
||||||
|
RouterModule.forRoot(routes)
|
||||||
|
],
|
||||||
|
declarations: [],
|
||||||
|
exports: [
|
||||||
|
RouterModule
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class AppRoutingModule {
|
||||||
|
}
|
||||||
@ -1,10 +1,26 @@
|
|||||||
import { Component } from '@angular/core';
|
import {Component, OnInit} from '@angular/core';
|
||||||
|
import {ActivatedRoute} from '@angular/router';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
templateUrl: './app.component.html',
|
templateUrl: './app.component.html',
|
||||||
styleUrls: ['./app.component.scss']
|
styleUrls: ['./app.component.scss']
|
||||||
})
|
})
|
||||||
export class AppComponent {
|
export class AppComponent implements OnInit {
|
||||||
title = 'koersepublicfrontend';
|
title = 'koersepublicfrontend';
|
||||||
|
|
||||||
|
private idChampionship: number;
|
||||||
|
|
||||||
|
constructor(private route: ActivatedRoute) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
// listen to the path ... what's the championship we're at?
|
||||||
|
this.route.paramMap.subscribe(val => {
|
||||||
|
this.idChampionship = +val.get('idchampionship');
|
||||||
|
console.log('APP CHAMP');
|
||||||
|
console.log(val);
|
||||||
|
console.log(this.idChampionship);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,17 +3,23 @@ import {NgModule} from '@angular/core';
|
|||||||
|
|
||||||
import {AppComponent} from './app.component';
|
import {AppComponent} from './app.component';
|
||||||
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
|
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
|
||||||
import {MatButtonModule, MatCardModule, MatCheckboxModule, MatTableModule} from '@angular/material';
|
import {MatButtonModule, MatCardModule, MatCheckboxModule} from '@angular/material';
|
||||||
import {RouterModule, Routes} from '@angular/router';
|
import {RouterModule, Routes} from '@angular/router';
|
||||||
import {TopmenuComponent} from './topmenu/topmenu.component';
|
import {TopmenuComponent} from './topmenu/topmenu.component';
|
||||||
import {ReclamespinnerComponent} from './reclamespinner/reclamespinner.component';
|
import {ReclamespinnerComponent} from './reclamespinner/reclamespinner.component';
|
||||||
import {PouleComponent} from './content/poule/poule.component';
|
import {PouleComponent} from './content/poule/poule.component';
|
||||||
import {TierComponent} from './content/tier/tier.component';
|
import {TierComponent} from './content/tier/tier.component';
|
||||||
import {HttpClient, HttpClientModule} from '@angular/common/http';
|
import {HttpClientModule} from '@angular/common/http';
|
||||||
import {Http} from '@angular/http';
|
import {AppRoutingModule} from './app-routing.module';
|
||||||
|
|
||||||
const appRoutes: Routes = [
|
const appRoutes: Routes = [
|
||||||
{path: 'championship/:idchampionship/tier/:tier', component: TierComponent},
|
{path : '', pathMatch: 'full', component: AppComponent},
|
||||||
|
{
|
||||||
|
path: 'championship/:idchampionship',
|
||||||
|
children: [
|
||||||
|
{path: 'tier/:idtier', component: TierComponent}
|
||||||
|
]
|
||||||
|
},
|
||||||
// { path: 'hero/:id', component: HeroDetailComponent },
|
// { path: 'hero/:id', component: HeroDetailComponent },
|
||||||
// {
|
// {
|
||||||
// path: 'heroes',
|
// path: 'heroes',
|
||||||
@ -37,15 +43,12 @@ const appRoutes: Routes = [
|
|||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
|
AppRoutingModule,
|
||||||
BrowserAnimationsModule,
|
BrowserAnimationsModule,
|
||||||
HttpClientModule,
|
HttpClientModule,
|
||||||
MatButtonModule,
|
MatButtonModule,
|
||||||
MatCheckboxModule,
|
MatCheckboxModule,
|
||||||
MatCardModule,
|
MatCardModule,
|
||||||
RouterModule.forRoot(
|
|
||||||
appRoutes
|
|
||||||
// { enableTracing: true } // <-- debugging purposes only
|
|
||||||
)
|
|
||||||
],
|
],
|
||||||
providers: [],
|
providers: [],
|
||||||
bootstrap: [AppComponent]
|
bootstrap: [AppComponent]
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import {Component, OnInit} from '@angular/core';
|
||||||
|
import {ActivatedRoute} from '@angular/router';
|
||||||
|
import {ChampionshipService} from '../../championship.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-tier',
|
selector: 'app-tier',
|
||||||
@ -7,7 +9,15 @@ import { Component, OnInit } from '@angular/core';
|
|||||||
})
|
})
|
||||||
export class TierComponent implements OnInit {
|
export class TierComponent implements OnInit {
|
||||||
|
|
||||||
constructor() { }
|
constructor(private route: ActivatedRoute, private championshipService: ChampionshipService) {
|
||||||
|
|
||||||
|
// mark the championservice to set the right championship
|
||||||
|
route.paramMap.subscribe(val => {
|
||||||
|
console.log(val);
|
||||||
|
this.championshipService.setChampionship(+val.get('idchampionship'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import {Component, OnInit} from '@angular/core';
|
import {Component, OnInit} from '@angular/core';
|
||||||
import {ChampionshipService} from '../championship.service';
|
import {ChampionshipService} from '../championship.service';
|
||||||
import {ActivatedRoute} from '@angular/router';
|
import {ActivatedRoute, Router} from '@angular/router';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-topmenu',
|
selector: 'app-topmenu',
|
||||||
@ -12,21 +12,17 @@ export class TopmenuComponent implements OnInit {
|
|||||||
private idChampionship: number;
|
private idChampionship: number;
|
||||||
|
|
||||||
constructor(private championshipService: ChampionshipService,
|
constructor(private championshipService: ChampionshipService,
|
||||||
private route: ActivatedRoute) {
|
private route: ActivatedRoute,
|
||||||
|
private router: Router) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
// listen to the path ... what's the championship we're at?
|
|
||||||
this.route.paramMap.subscribe(val => {
|
|
||||||
this.idChampionship = +val.get('idchampionship');
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
currentChampionship(): string {
|
currentChampionship(): string {
|
||||||
const anies = this.championshipService.getChampionships().filter(val => val.idchampionship === this.idChampionship);
|
const currentChampionship = this.championshipService.getCurrentChampionship();
|
||||||
if (anies && anies[0]) {
|
if (currentChampionship) {
|
||||||
return anies[0].name;
|
return currentChampionship.name;
|
||||||
} else {
|
} else {
|
||||||
return '?';
|
return '?';
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user