angular 2 - bind object to dropdown and select value based on an event

后端 未结 2 564
灰色年华
灰色年华 2021-01-17 07:18

I have created a dropdown which has suppliers bound to it as an object.


                        
    
提交评论

  • 2021-01-17 07:24

    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.

    0 讨论(0)
  • 提交回复
    热议问题