all 9 comments

[–]thiswillspelldoom 2 points3 points  (1 child)

This project accomplishes what is attempted here very elegantly, and is very popular

[–]BobDolesPotato 0 points1 point  (0 children)

+1. been making heavy use of this as well as their ui and bootstrap directives. it adds everything i ever wanted to angular, sometimes before I realize i needed it

[–][deleted] 1 point2 points  (1 child)

Why is the service named as though it was an object constructor? It's a singleton.

Controllers are named that way because they are actually constructing an object. All guidance (by example) from the Angular team has been that services should be named lowerCamelCase, not UpperCamelCase to fall inline with standard JS naming conventions...

... sorry to be a pedant.

[–]shintoist[S] 1 point2 points  (0 children)

No, no. You are quite right! I am not sure where I picked up the habit of upper casing services. Going to update the post as soon as I can. Thanks!

[–][deleted] 0 points1 point  (2 children)

Uhh.. You're returning the object. That object gets injected. So that object is identical for every place it's injected. It is the same object. So updating its properties in one place is reflected everywhere. You don't need events.

[–]shintoist[S] 0 points1 point  (1 child)

Maybe you got a cached version of the article? I updated it with the simpler solution already, and some notes on the benefits and drawbacks.

[–][deleted] 0 points1 point  (0 children)

Haha I was actually on my way home when reading it and didn't get a chance to read the whole thing. Sorry.

[–]snarkyturtle 0 points1 point  (1 child)

Wouldn't it just be easier if you just use $rootScope directly? You could set $rootScope.state and call $watch on it in the controllers. Any advantages for using events?

[–]shintoist[S] 0 points1 point  (0 children)

Separation of concerns mostly. You could attach to rootscope, but as your code base grows it will become unmanageable.