Hi Sander, Thanks for the reply and assistance. Not sure that's exactly what is happening. I am actually using a getter/setter in ServiceA to set the (boolean) value and then in ServiceB I call the getter in ServiceA ... obviously after the value has been updated. I even put a timer on it just to ensure it was updated. If I console.dir(ServiceA) from ServiceB after the value was updated in ServiceA, it still shows the original value. You mention in your reply, "Unless you provided the services elsewhere", are you referring to listing them in the Providers array in a Module - as I am not doing that?
I can provide truncated version of the services and component if it would help. Thanks, Scott On Mon, Dec 10, 2018 at 9:15 AM Sander Elias <sanderel...@gmail.com> wrote: > Hi Scott, > > Unless you provided the services elsewhere, they are singletons. I suspect > that you are using primitives. As primitives are assigned by value and not > by reference. > > import { Injectable } from '@angular/core'; > > @Injectable({ providedIn: 'root' }) > export class test1Service { > public someVar = '100'; > constructor() {} > } > > @Injectable({ providedIn: 'root' }) > export class test2Service { > someRef = this.t.someVar; > constructor(private t: test1Service) {} > } > > > If you have something like that, the someRef will never updates, as it > copies the value. A solution might be using a getter: > > @Injectable({ providedIn: 'root' }) > export class test2Service { > someRef = () => this.t.someVar; > constructor(private t: test1Service) {} > } > > someRef is now a function that will return the current value. > > Hope this helps, > Regards > Sander > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Angular and AngularJS discussion" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/angular/HmHBWjhux-o/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > angular+unsubscr...@googlegroups.com. > To post to this group, send email to angular@googlegroups.com. > Visit this group at https://groups.google.com/group/angular. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group. To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscr...@googlegroups.com. To post to this group, send email to angular@googlegroups.com. Visit this group at https://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.