Check out my TypeScript component below
export interface Product{
id?:string,
name:string,
price:string;
quantity:string;
tags:Tags[];
description:string;
files: File[];
}
product$:Observable<Product | undefined>;
ngOnInit(): void {
this.store.dispatch(new productActions.LoadProduct(fromProduct.getCurrentProductId.toString()));
this.product$ = this.store.pipe(select(fromProduct.getCurrentProduct));
}
The last two statements retrieve the value of the product observable and function properly.
this.product = this.fb.group({
name:['',[
Validators.required,
Validators.minLength(1),
Validators.maxLength(128)
]],
price:['',
Validators.required],
tags:this.fb.array(this.tags),
quantity:['',Validators.required],
description:['',
Validators.required]
});
}
My current aim is to set the default Form values from Product$ (observable)
In the above code, the default value for name is set to ''. However, I would like to set a default value from (product$ | async).name----->> This functionality works correctly in HTML, but I am unsure how to implement it in TypeScript.
Thank you for your assistance.