It seems that each component that creates its own instance of [a] service. I don't understand why.
I note this AngularJs 2 - multiple instance of service created, but I'm not clear on the correct solution. Do I create the service instance _myService
in main:
void main() {
bootstrap(AppComponent,[MyService]);
}
and then copy it to [child] components (because I also remove MyService
from the component providers)? This doesn't seem correct, because the components reference _myService
before it's instantiated, and I have to check it for being null.
Thanks
Steve