I get an error to show the results of my service call. The html page has ngFor with | asynchronous. I can make a call, get the results, but get an error when I try to make a page. I know that a variable must be observable for async to work. I'm not sure what I am doing wrong, and have tried several things. Any insight appreciated.
Error message: Invalid argument "Object Object", [Object Object], [Object Object], [Object Object], [Object Object], [Object Object], [Object Object], [Object Object], [Object Object] , [Object Object], [Object Object], [Object Object], [Object Object], [Object Object], [Object Object], [Object Object], [Object Object], [Object Object], [Object Object] , [Object Object] 'for the pipe' AsyncPipe '
Variable value
public products:Observable<Product[]>;
Service call
ngOnInit() { this.productService.load().subscribe( data => { // Set the products Array this.products = data['_embedded'].products; }, error => console.log('Could not find product catalog.') );
}
Service call
load() { return this._http.get(`http://localhost:8000/products`).map(response => response.json()); }
HTML
<tbody *ngFor="let product of products | async"> <tr> <td>{{product.sku}}</td> <td>{{product.materialNumber}}</td> <td>{{product.price}}</td> <td>{{product.baseUom}}</td> <td>{{product.packageSize}}</td> <td>{{product.casePack}}</td> <td>{{product.weight}}</td> <td>{{product.height}}</td> </tr> </tbody>
Call data

angular angularjs-directive
Don
source share