Ich habe tow Auswahllisten (select1 und select2) in meinem Formular, select2 hängt von select2 Auswahl, wenn select1 Auswahl ändern Optionen in select2 muss ändern das funktioniert gut, aber mein Problem ist das bei Änderung don 't Rückkehr zu Standard-Option, gibt es mir letzten Index der letzten select2 Auswahl, ich will bei Änderung der select2 Option ändern und Index der ausgewählten Option zurück zu 0 oder Standardoption Ich benutze ng-Modell, um mit select in angular2 umzugehenwie man wählt in angular2
dies mein hTML-Code:
<td *ngIf="classificationCheck"><select name="classification_type" [(ngModel)]="message.classification_type"
class="form-control" [disabled]="isReply||isForward">
<option value="" disabled default>تصنيف موضوعي</option>
<option *ngFor= "let subType of classificationTypes">{{subType}}</option>
</select></td>
und diese onChange Funktion für select1 Hexe Update select2 Optionen:
classificationChange(event){
if("غير محدد"==event){
this.classificationCheck=false;
this.message.classification_type=null;
}
else{
for(let classtype of this.classifications){
if(classtype.gen==event){
if(classtype.name)
{
this.classificationTypes=[];
this.classificationCheck=true;
for(let subType of classtype.name){
this.classificationTypes.push(subType);
}
}
}
}
}
}
Bitte Code angeben. Und bitte verwenden Sie Interpunktion, die Frage ist kaum lesbar. –
Bitte erstellen Sie ein [pnlkr] (https://plnr.co/) und ja, es ist extrem schwierig, Ihre Frage zu entschlüsseln. – sisyphus
ich aktualisierte es durch Code –