Does anyone know how to properly display object values in forms using Angular? I can see the object and its values fine in the browser developer tools, but I'm having trouble populating the form with these values.
In my *.ts file:
console.log(this.product), // {"productId": "3", "productName": "G500 cpu", "productDescription": "gaming computer", "productCategory": "computers", "units": 5 }
this.updateForm.patchValue({
// productId: '23128', // display 23128
// productName: 'asdas', // display asdas
productId: this.product.productId, // doesn't display anything
productName: this.product.productName // doesn't display anything
// productId: this.product, // display [object Object]
// productName: this.product // display [object Object]
})
In my *.html file:
<form [formGroup]="updateForm">
<div class="form-group">
<input
type="text"
class="form-control"
formControlName="productId">
</div>
<div class="form-group">
<input
type="text"
class="form-control"
formControlName="productName"
/>
</div>