davej / angular-classy

Cleaner class-based controllers with Angular 1
http://davej.github.io/angular-classy/
813 stars 27 forks source link

Angular Classy with directives. #35

Closed trusktr closed 10 years ago

trusktr commented 10 years ago

Suppose you have an app that uses directives extensively with logic mostly in the link functions, rather than in controllers. How would you recommend I bring classy into play? Should I use the controller property of the directive definition to define a Classy controller and move logic into there?

davej commented 10 years ago

It's really up to you. Using Classy for a directive's controller was not a core use-case, it was more of an after-thought.

Personally, I put my main logic in the directive controller and then put DOM interactions in the link function. That's not necessarily more correct than putting your logic in the link function though. I certainly wouldn't go re-writing existing directives just so they can use Classy for the controller.

There will ultimately be Classy directives but I haven't decided what that will look like yet. If you have any ideas then you can add them to issue #1.