I have this method, when choosing a country, search the states.
filtrarEstado(pais : Pais) : void{
this.loading = true;
this.estadoService.getEstadosPorPais(pais).subscribe(
(data :any) => {
this.estados = data.lista;
this.loading = false;
}
);
}
Component in HTML
<mat-form-field class="formulario-full-width">
<mat-select placeholder="País" name="pais"
[(ngModel)]="municipioBuscar.paisId"
matTooltip="Deve selecionar um país">
<mat-option (blur)="filtrarEstado(0)">Nenhum</mat-option>
<mat-option *ngFor="let pais of paises" [value]="pais"
(blur)="filtrarEstado(pais)">{{pais.descricao}}
</mat-option>
</mat-select>
</mat-form-field>
But when I choose none , it does not execute the filterState method, so the state component is populated with states from the last chosen country.
What's wrong?