PrimeNG DataTableを使用してAngular 2アプリケーションで非常に奇妙な問題が発生しています。 [editable]"true"
構文を使用して、DataTableのデータを変更することは可能です。Angular 2で予期しないバインディングが発生しました
DataTableのデータは、inschrijvingen
と呼ばれます。 私はthis.originalInschrijvingen = this.inschrijvingen
を使って 'コピー'を作成してから、ユーザーがデータを変更して後の段階で変更を比較できるようにしています。しかし何らかの理由でDataTableのデータバインディングがoriginalInschrijvingen
とinschrijvingen
の両方にバインドされています。ここで
は私のコードです:
onRowSelectUser(event) { //This is a different DataTable than the editable DataTable
this.getGebruikerZijnInschrijvingen(res => {
this.createRoleID(res => {
let selectedIds = this.gebruikerZijnInschrijvingen.map(it => it.DefUnitID);
this.selectedInschrijvingen = this.inschrijvingen.filter(inv => selectedIds.indexOf(inv.ID) != -1);
this.originalInschrijvingen = this.selectedInschrijvingen;
})
})
}
プログラミングで参考文献を読んでいても助かります。 https://en.wikipedia.org/wiki/Reference_(computer_science) – toskv
ありがとうございます!私はそれが「コピー」の代わりに参照していることを知らなかった。ありがとう! –
@Pengyy返事ありがとうございますが、私はすでに答えが見つかったと思います。[リンク](https://stackoverflow.com/a/21896214/4461137) –