0
を働いていないバインディング私が持っている、私は私のaccountTypes
配列の最初の要素をバインドしようとすると角度2つのデータは私のTSで
<div *ngFor="let question of section?.questions">
<select class="q-select"
[(ngModel)]="acttypetest" // BIND HERE
name="answerForQuestion{{ question?.questionId }}">
<optgroup label="{{subCat?.subCat}}"
*ngFor="let subCat of accountTypes; let i = index;">
<option *ngFor="let acctType of accountTypes"
[ngValue]="acctType">
{{ acctType?.displayName }}
</option>
</optgroup>
</select>
</div>
このようなacttypetest
にそれが正常に動作します:
setSelectedAcctType() {
this.acttypetest = this.accountTypes[0];
}
しかし、私はのレギュレーションで(このようにそれをバインドしようが正確私accountTypes
配列の最初の要素と一致していることをRのオブジェクトは、それが仕事をdoesntの:なぜ第二の方法の仕事doesntの
setSelectedAcctType() {
this.acttypetest = {
accountTypeId: 1,
displayName: "Individual - Taxable",
isTaxable: 1,
subcategory: "Taxable"
};
}
それは私のaccountTypes
配列の最初の要素とまったく同じフォーマットされたオブジェクトである場合には?
正確な外観の2つのリンゴは、まだ2つの異なるリンゴとしてカウントされます。 –
スキーマや値によっても一致しても、メモリ内の同じオブジェクトを参照していません。 – lbrahim