I need help filling a form value by id.
This function successfully retrieves the value:
fillFormValues(expenseCategory: ExpenseCategory): void {
console.log('response', expenseCategory.parent_category)
this.aa= expenseCategory.parent_category;
console.log(this.aa.name)
this.expenseCategoriesEditForm.get('parent_category')?.setValue(this.aa.name); //it doesn't function
this.expenseCategoriesEditForm.get('name')?.setValue(expenseCategory.name); // function ok
}
In my HTML file, I have the following code:
<mat-select formControlName="parent_category" id="parent_category">
<mat-option *ngFor="let p_g of expenseCategories" [value]="p_g.id">
{{p_g.name}}
</mat-option>
</mat-select>
I want to show in the view
this.expenseCategoriesEditForm.get('parent_category')?.setValue(this.aa.name); //it doesn't function
Any ideas or suggestions would be greatly appreciated. Thank you!