Back to overview

Angular Add New Item to List

Angular
merge(
  this.products$,
  this.insertAction$.pipe(
    concatMap((newProd) => {
      return this.http.post<Product>(this.url, newProd);
    }),
  ),
).pipe(scan((acc, value) => (value instanceof Array ? [...value] : [...acc, value]), [] as Product[]));