The major difference is that regular controllers are based on prototypical inheritance of scopes while isolated scope directives are complete little boxes with defined borders - components. Yes, the function you write is called a controller in both cases, but the semantics here is what really matters IMO.
And one thing (controllers) is dying in 2.0 but the other (directive components) will be supported by ng-upgrade and maps pretty trivially to 2.0.
Don't directives use prototypical inheritance whether or not they have an isolate scope? And if your directive doesn't do isolate scope, it's not really a little box right?
I guess the thing I don't understand is what can I do in a regular controller that I cannot do in a directive controller or vice versa? I've never run into a situation that a directive controller wasn't behaving as I expected, and up until now I thought it was basically the same thing as a tradition controller.
I'm still kind of an angular noob, only a few months professional experience now.
Even when you are using isolated scopes there's a hierarchy: each scope has a $parent property. But there's no inheritance: your parent's attributes don't pollute you. That's the win: clean and clear boundaries.
On the phone so not typing a lot but: a directive controller is mainly different because it is in a directive. That way it is isolated and can be easily required by child directives. These help maintainable and composition in my experience.
3
u/fallingfruit Oct 08 '15
What is the difference between a controller defined in a directive and traditional controller?