Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • the example you gave seems to work as long as the updateViaHttp doesnt return an object. if so, and I assign srvc.sharedVar = returnedObj it breads the reference. is that true? Commented May 14, 2015 at 16:17
  • You can totally have nested objects inside of services, the only trick to it is that you have to be careful with how you're watching that value. The link I had there about watch depths talks about it more, but basically you can have issues when you change the properties but not the object, as then the object won't mark itself as "changed". Similarly, you have to be careful with how you watch a service's properties, see: stsc3000.github.io/blog/2013/10/26/… Services are just singleton objects used by your whole app Commented May 14, 2015 at 16:32
  • can't get it to work, it I change the view the state of the factory is lost. its not persistent Commented May 14, 2015 at 17:50
  • 1
    Where are you declaring the service? How are you injecting it into your views? There's a lot that could be going on here, so it might be worthwhile for you to run through the official Angular service documentation to make sure you're checking all the boxes: docs.angularjs.org/guide/services Commented May 15, 2015 at 0:31