-2
import { MatchService } from './../match.service';
import { Router } from '@angular/router';
import { Component, OnInit } from '@angular/core'
import { Match } from '../match.model';
import {FormControl, Validators} from '@angular/forms';
import { MatchCreateService } from './match-create.service';
import { templateSourceUrl } from '@angular/compiler';
@Component({
selector: 'app-match-create',
templateUrl: './match-create.component.html',
styleUrls: ['./match-create.component.css']
})
export class MatchCreateComponent implements OnInit {
teams: Team[] = [];
selectedAwayTeam = this.teams[1];
selectedHomeTeam = this.teams[0];
match: Match = {
homeTeam: '',
awayTeam: '',
goalsHomeTeam: 0,
goalsAwayTeam: 0
}
/*logo: Blob[] = this.teams[1].logo;*/
constructor(private matchService: MatchService, private router: Router,
private matchCreateService: MatchCreateService) { }
ngOnInit(): void {
this.getTeams();
}
getTeams(){
this.matchCreateService.getTeams().subscribe(teams => {
console.log(teams[8].srcLogo);
this.teams = teams;
})
}
createMatch(): void {
this.matchService.create(this.match).subscribe(() => {
this.matchService.showMessage('Partida criada com sucesso!')
this.router.navigate(['/matches'])
})
}
cancel(): void {
this.router.navigate(['/matches']);
}
teste(elemento: any){
console.log(elemento)
}
}
The first element selected comes Undefined, the second comes the first element I showed and so on
I would just like to pick up the selected element. I am using Angular 11