且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

角度2-将对象绑定到下拉列表并根据事件选择值

更新时间:2022-06-03 03:21:15

似乎Angular2使用对象引用而不是属性,因此,如果这样做,它将起作用:

It seems Angular2 uses objects reference, instead of properties, so if you do this, it will work:

private onEdit(relationship: Relationship): void {
  this.selectedSupplier = this.suppliers.find(supplier => supplier.id === relationship.supplierId);
}

您需要传递与选择对象完全相同的对象.

You need to pass the exact same object from the select.