47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import {Component} from "@angular/core";
|
|
import {Player, War} from "../models/model-interfaces";
|
|
import {WarService} from "../services/war-service/war.service";
|
|
import {ActivatedRoute} from "@angular/router";
|
|
|
|
|
|
@Component({
|
|
selector: 'war-detail',
|
|
templateUrl: './war-detail.component.html',
|
|
styleUrls: ['./war-detail.component.css']
|
|
})
|
|
export class WarDetailComponent {
|
|
|
|
war: War = {players: []};
|
|
|
|
players: Player[] = [];
|
|
|
|
fractionRadioSelect: string;
|
|
|
|
constructor(private route: ActivatedRoute,
|
|
private warService: WarService) {
|
|
}
|
|
|
|
ngOnInit() {
|
|
this.route.params
|
|
.map(params => params['id'])
|
|
.filter(id => id != undefined)
|
|
.flatMap(id => this.warService.getWar(id))
|
|
.subscribe(war => {
|
|
this.war = war;
|
|
this.players = war.players;
|
|
});
|
|
}
|
|
|
|
filterPlayersByFraction(fraction: string) {
|
|
if (fraction) {
|
|
this.players = this.war.players.filter((player) => {
|
|
console.log(player.fraction + " .... " + fraction);
|
|
return player.fraction === fraction;
|
|
})
|
|
} else {
|
|
this.players = this.war.players;
|
|
}
|
|
}
|
|
|
|
}
|