There's a lot of conversation about the redundant injector syntax in this thread. This is something that ngmin takes care of completely transparently. There's really no need to worry about it in raw, uncompressed source code. Other than that, this provides a nice way to enforce a certain set of conventions, but I'm not completely sold on the quality of those conventions - the most glaring thing being losing reference…
Classy: Cleaner class-based controllers for AngularJS
51–59 of 59 posts
Re: Classy: Cleaner class-based controllers for AngularJS
#52Oh wow, this is my little project, cool to see it on the front page of Hacker News. :-)
It's a really nice demo page. What do you use for the code highlighting?
Fun geek fact: The Mac OS style close/minimize/expand buttons on the code editor are written in CSS, they're not images. A bit of a pointless exercise but a fun little easter egg.
Re: Classy: Cleaner class-based controllers for AngularJS
#53Oh wow, this is my little project, cool to see it on the front page of Hacker News. :-)
Re: Classy: Cleaner class-based controllers for AngularJS
#54Typescript classes work nicely with Angular controller I find. Coffeescript ones too.
Afaik you cant declare anonymous classes in typescript,let alone wrapping them in a closure. No problem with Coffeescript. module.controller 'MainCtrl', class constructor:($scope,bar,baz)-> $scope.message="foo" @$inject = ['$scope','bar','baz'] that's why i prefer the later.types or not.
Re: Classy: Cleaner class-based controllers for AngularJS
#55Earlier quoted context omitted.
I can see Classy adding value, but repetition with dependency injection is a solved problem if you use ngmin[1]. [1]: https://github.com/btford/ngmin
I disagree that ngmin is a full solution to the problem. It is a good and very helpful tool, but it's a hack and a pretty leaky one - I think it's often less of a hassle to just write all the explicit injection syntax myself than to fiddle with formatting to get ngmin to work and track down issues when it doesn't. Classy's solution seems much nicer to me.
Re: Classy: Cleaner class-based controllers for AngularJS
#56I guess this can clean logic flow in a controller, but here you end up with a bloated object instead. The biggest problem I see though is if you want to save a reference to the unregister functions of the $watch callbacks. Otherwise, this is a cool idea, although it falls a little short.
> The biggest problem I see though is if you want to save a reference to the unregister functions of the $watch callbacks. This is a valid criticism, thank you. I will try to put together a nice solution for this. Of course you can always register/de-register watchers the normal way inside of the init method.
Re: Classy: Cleaner class-based controllers for AngularJS
#57Earlier quoted context omitted.
I disagree that ngmin is a full solution to the problem. It is a good and very helpful tool, but it's a hack and a pretty leaky one - I think it's often less of a hassle to just write all the explicit injection syntax myself than to fiddle with formatting to get ngmin to work and track down issues when it doesn't. Classy's solution seems much nicer to me.
I have no idea what you're talking about; I've never had any issues with ngmin or angular's default (i.e. non-array / string) injection methods.
Re: Classy: Cleaner class-based controllers for AngularJS
#58This is actually great for someone learning Angular. It's just a different way of presenting the exact same material. I was completely dumbfounded at first when learning Angular. This would have helped. I very much suggest everyone interested in Angular development to read what the guys at MeanJS.org[1] have to say about structuring modules. It helps me think about my app a lot better. The structure could be cleaned…
Re: Classy: Cleaner class-based controllers for AngularJS
#59Oh wow, this is my little project, cool to see it on the front page of Hacker News. :-)
So long as non-Classy controllers are still operable (which I assume they are), then I should be able to port individual controllers one at a time without disturbing un-ported controllers, then this is exactly what Angular was needing, IMO.