I would like to update values in the "specialisation" mat-select" when I select a skill in my "competence" mat-select. I linked my var with the model using [(ngModel)]
but it won't update the list.
I tried to use ngModel, with angular & material 7.
HTML:
<mat-form-field>
<mat-select name="competence_1_name" [(ngModel)]="competence_1.name">
<mat-option>-- Faites un choix --</mat-option>
<mat-option *ngFor="let competence of competences" value="{{competence.name | lowercase}}">{{competence.name}}</mat-option>
</mat-select>
<mat-label>Compétence</mat-label>
</mat-form-field>
[...]
<mat-form-field>
<mat-select name="competence_1_spe_1" [(ngModel)]="competence_1.specialisation_1">
<mat-option>-- Faites un choix --</mat-option>
<mat-option *ngFor="let specialisation of competence_1.specialisation_list" value="{{specialisation | lowercase}}">{{specialisation}}</mat-option>
</mat-select>
<mat-label>Spécialisation</mat-label>
</mat-form-field><br>
main class:
export class GeneratePnjComponent implements OnInit {
competences: Array<Competence>;
masteries: Array<string>;
competence_1 = new Competence("");
competence_2 = new Competence("");
competence_3 = new Competence("");
name: string;
cost: number;
time: number;
...
}
Class for a skill:
export class Competence {
name: string;
mastery: string;
specialisation_1: string;
specialisation_2: string;
specialisation_list: Array<string>;
constructor(name: string) {
this.name = name;
this.specialisation_list = new Array<string>();
}
}
Expected result: the list 'competence_1_spe_1' update when I choose a value on the list 'competence_1_name'
Actual result: No value in the list 'competence_1_spe_1' even if I choose a value in the list 'competence_1_name'