I have been trying to share data between components and followed advice from here to make a store.
It all works great from within my components constructor but I can't figure out how to give the functions similar access.
class Home {
constructor($scope, $reactive, Store) {
'ngInject';
$reactive(this).attach($scope);
this.selectedDate = Store.get().selectedDate;
}
That all works, but accessing the Store here doesn't work:
nextDay(){
'ngInject';
Store.set({selectedDate: moment(this.selectedDate).add(1, 'd').format('YYYY-MM-DD')});
console.log('nextDay');
}
I have tried attaching Store to $reactive, I have tried this.Store and passing Store as an agrument to nextDay() but can't figure it out. Any help would be greatly appreciated.
Thanks