I am absolute beginner in Angular2,
this are my components,how to update this.product Array in HeaderComponent , whenever buynow() is triggered in FoodDetailsComponent
export class HeaderComponent {
products: Array < any > ;
cart: Array < any > ;
Tabs: Array < any > ;
constructor(public ShopDataService: ShopDataService) {
this.products = this.ShopDataService.get();
}
ngOnInit() {}
}
export class FoodDetailsComponent {
@Input()
foodDetail: any;
constructor(private ShopDataService: ShopDataService) {
}
buynow(product) {
this.ShopDataService.add(product);
}
ngOnInit() {}
}
And i have few doubts how change Detection work,changeDetectionStrategy is only for child-parent component.how about sibling component works?
onPush