I have played with both strategies. Services are nice but as you point out they add a layer of complexity.If you are going to assign it to the scope I suspect you will be triggering digests when it changes anyway, although I don't know if the guys at Google (GaGs) have optimized this at all.
So there is not much benefit to be had there.
By the way, if you have an object stored at the root, you can change its fields on any scope without having to resort to scope.$root.
The benefits of services come from modularity and being able to hide implementaction details from the controllers.
Pete
...from my mobile.
--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/angular?hl=en.
I have played with both strategies. Services are nice but as you point out they add a layer of complexity.If you are going to assign it to the scope I suspect you will be triggering digests when it changes anyway, although I don't know if the guys at Google (GaGs) have optimized this at all.
So there is not much benefit to be had there.
By the way, if you have an object stored at the root, you can change its fields on any scope without having to resort to scope.$root.
--
If you assign to a property on a property of scope then it is the original property on the parent scope that is updated.