rxjs/Subscription undefined value of another subscription -
i need use value of subscription subscription. here code. product value undefined, best method access value?
code:
@component({ selector: 'product-page', templateurl: 'product-page.html' }) export class productpage { private product: product; this.store.select('products').subscribe(({ product }) => { if (product) { this.product = product; } }); this.store.select('plc').subscribe((value: any) = > { console.log(this.product); // undefined }) }
you can combine 2 selections using combinelatest
operator:
import 'rxjs/add/operator/combinelatest'; // ... this.store .select('products') .combinelatest(this.store.select('plc')) .subscribe(([products, plc]) => { // ... });
Comments
Post a Comment