When there is no value, how to initialize a observable
value? either i am not set empty value as well.
code :
interface PropsProduct {
id: number,
picture: string,
price: number,
name: string,
combo: boolean,
discount: number
}
myArray: Observable<PropsProduct>
constructor(private readonly dataService: DataService) {
this.myArray = [] //throws the error;
}
CodePudding user response:
Use of to initiate observable
import { of } from 'rxjs';
this.myArray = of([]);