0

In this StackBlitz example https://stackblitz.com/edit/comunicar-components:

How can I change the style of div in row-hours-control.component when I press Button1 in row-card.component?

How can I remove Button1 in row-hours-component and Button2 in row-hours-control.component when I press Button1 in row-card.component?

mamjerez
  • 15
  • 5
  • 2
    There are a few ways to do it. You need to either utilize an external service to communicate between the two components, or you can use `@Output` to signal an event that is passed in by `@Input`. The external service is probably the better way. If this is **all** you need to do, maybe you can watch an external state diagram and update the template dependent on the state that is observed. – Rich Jun 13 '19 at 16:51
  • 2
    What @Rich mentioned is explained in details with examples in [Angular guide](https://angular.io/guide/component-interaction). – k0hamed Jun 13 '19 at 16:55
  • Some time along I made a stackbliz to show how comunicate two component via service using a variable or using subject. the question in stackoverflow: https://stackoverflow.com/questions/48112868/call-function-from-one-component-to-another-to-update-the-button?noredirect=1&lq=1, the stackblitz: https://stackblitz.com/edit/angular-rrv6hs?file=src%2Fapp%2Ffooter.component.ts – Eliseo Jun 13 '19 at 19:24

0 Answers0