diff --git a/SystemKonkursow/4.2.1/angular/src/app/app-routing.module.ts b/SystemKonkursow/4.2.1/angular/src/app/app-routing.module.ts index 7a7daaf..8245a31 100644 --- a/SystemKonkursow/4.2.1/angular/src/app/app-routing.module.ts +++ b/SystemKonkursow/4.2.1/angular/src/app/app-routing.module.ts @@ -25,7 +25,7 @@ import { CompetitionDetailComponent } from '@app/competition-detail/competition- { path: 'about', component: AboutComponent }, { path: 'categories-list', component: CategoriesListComponent, canActivate: [AppRouteGuard] }, { path: 'categories-list/:id', component: CompetitionsListComponent, canActivate: [AppRouteGuard] }, - { path: 'categories-list/:id/:competitionId', component: CompetitionDetailComponent, canActivate: [AppRouteGuard] } + { path: 'competitions/:id', component: CompetitionDetailComponent, canActivate: [AppRouteGuard] } ] } ]) diff --git a/SystemKonkursow/4.2.1/angular/src/app/competition-detail/competition-detail.component.ts b/SystemKonkursow/4.2.1/angular/src/app/competition-detail/competition-detail.component.ts index 876371b..8d9d717 100644 --- a/SystemKonkursow/4.2.1/angular/src/app/competition-detail/competition-detail.component.ts +++ b/SystemKonkursow/4.2.1/angular/src/app/competition-detail/competition-detail.component.ts @@ -1,6 +1,8 @@ import { Component, OnInit, Injector, OnDestroy } from '@angular/core'; import { appModuleAnimation } from '@shared/animations/routerTransition'; import { AppComponentBase } from '@shared/app-component-base'; +import { Subscription } from 'rxjs/Rx'; +import { ActivatedRoute } from '@angular/router'; @Component({ templateUrl: './competition-detail.component.html', @@ -9,18 +11,29 @@ import { AppComponentBase } from '@shared/app-component-base'; }) export class CompetitionDetailComponent extends AppComponentBase implements OnInit, OnDestroy { + private paramSubscription: Subscription; + + public competitionId: number; + constructor( injector: Injector, + private route: ActivatedRoute, ) { super(injector); } public ngOnInit() { - + this.paramSubscription = this.route.params + .subscribe(params => { + this.competitionId = +params['id']; + console.log('competitionId: ' + this.competitionId) + }); } public ngOnDestroy() { - + if (this.paramSubscription) { + this.paramSubscription.unsubscribe(); + } } } \ No newline at end of file diff --git a/SystemKonkursow/4.2.1/angular/src/app/competitions-list/competitions-list.component.ts b/SystemKonkursow/4.2.1/angular/src/app/competitions-list/competitions-list.component.ts index 8848f22..a947d51 100644 --- a/SystemKonkursow/4.2.1/angular/src/app/competitions-list/competitions-list.component.ts +++ b/SystemKonkursow/4.2.1/angular/src/app/competitions-list/competitions-list.component.ts @@ -58,8 +58,9 @@ export class CompetitionsListComponent extends AppComponentBase implements OnIni } public goToDetail(competition: CompetitionDto): void { - console.log(this.router.url); - const route: string = this.router.url + `/${competition.id}`; + //console.log(this.router.url); + //const route: string = this.router.url + `/${competition.id}`; + const route: string = `app/competitions/${competition.id}`; this.router.navigate([route]); }