Search code examples
angulartypescriptangular-services

Passing value to other component Angular


how can I change value of validCompo from other component please? Some people speak about Angular service to resolve that, but i don't understand how it works.. I have tried lot of things but nothing works...

Is it possible to show me on the example below the good way to resolve ?

https://stackblitz.com/edit/angular-sc7zsc

Thanks a lot!


Solution

  • Have the variable defined in the service. Inject the service in both components. In the event handler, update the variable in service, it will reflect in both places.