Reputation: 113
I have made one timer component and want to use it in two different places.
I want that if I start the timer at one place it should automatically start at the other and vice versa.
Using @Output and @ViewChild didn't work for me.
Upvotes: 0
Views: 58
Reputation: 819
You can use state management or save time in localstorage and fetch the time from there. This way, you can show the time anywhere you want.
Upvotes: 1
Reputation: 101
For your use case, I prefer you to use NGRX Module in angular with Subject for Sibiling.
For more info, checkout this out https://ngrx.io/guide/store
Upvotes: 0
Reputation: 1557
You can store the time variable in a service (outside the timer component), and so, all instances of the component will use the same time...
Upvotes: 1