Live data from Hacker News

AngularJS Style Guide

gocardless.com

1–10 of 41 posts

Re: AngularJS Style Guide

#2
The actual post title is: "The GoCardless AngularJS Style Guide". I was expecting something about how they needed to do XYZ to make Angular run well rather than how they scale up development.

Re: AngularJS Style Guide

#3
post #2

The actual post title is: "The GoCardless AngularJS Style Guide". I was expecting something about how they needed to do XYZ to make Angular run well rather than how they scale up development .

We changed the title to that (minus the domain name, as the HN guidelines ask). It used to be "Scaling AngularJS at GoCardless".

Re: AngularJS Style Guide

#4
I got a lot out of this. I’ve never worked in a platform that evolves as rapidly as Angular, and have found myself blinded by “last year’s advice” a few times. Quite a bit of modern thinking here.

Re: AngularJS Style Guide

#6
Very helpful. I've unsuccessfully search for a way to do one-time binding before in a data intensive application and never came across the {{::ctrl.foobar}} syntax.

One thing I'm hesitant about is their advice to use directives instead of ng-controller="MyCtrl". Since controllers really are app specific glue code I rarely find myself wanting to reuse them - what advantages are directives supposed to give here?

Re: AngularJS Style Guide

#7

Very helpful. I've unsuccessfully search for a way to do one-time binding before in a data intensive application and never came across the {{::ctrl.foobar}} syntax. One thing I'm hesitant about is their advice to use directives instead of ng-controller="MyCtrl". Since controllers really are app specific glue code I rarely find myself wanting to reuse them - what advantages are directives supposed to give here?

One-time binding is a 1.3.0 beta feature (check your version before using)!

Re: AngularJS Style Guide

#8
post #5

Todd Motto's angular style guide [1] has been one of the most helpful to me. It's always good to read multiple style guides and cherry-pick what works best for you :) [1]: https://github.com/toddmotto/angularjs-styleguide

The recommendations in the module section are pretty awful - I'd avoid doing so, and every other expert in the community I've spoken to also disagree with that suggestion of using global functions wrapped in an IIFE to prevent it from being published on window, which seems to exclusively come out of Google.

Re: AngularJS Style Guide

#9

Very helpful. I've unsuccessfully search for a way to do one-time binding before in a data intensive application and never came across the {{::ctrl.foobar}} syntax. One thing I'm hesitant about is their advice to use directives instead of ng-controller="MyCtrl". Since controllers really are app specific glue code I rarely find myself wanting to reuse them - what advantages are directives supposed to give here?

Directives are more powerful - for example, child directives can require the parent directive's controller and make use of it, which can lead to some powerful control flow.

You can also define a controller and have the directive consume it via named reference - here is one example that makes use of this: https://github.com/driftyco/ionic/blob/master/js/angular/dir...

Controllers should be consumed this way, so that they become easier to test. Testing directives can get complicated.

Re: AngularJS Style Guide

#10

Very helpful. I've unsuccessfully search for a way to do one-time binding before in a data intensive application and never came across the {{::ctrl.foobar}} syntax. One thing I'm hesitant about is their advice to use directives instead of ng-controller="MyCtrl". Since controllers really are app specific glue code I rarely find myself wanting to reuse them - what advantages are directives supposed to give here?

You can easily get one-time bindings using https://github.com/kseamon/fast-bind, which supports not only one-time bindings but also updating a binding only when called.

This makes it easy to work with data that doesn't change, promises, or large amounts of data that rarely changes.

Karl Seamon did a great talk about performance this past January at ng-conf as well, https://www.youtube.com/watch?v=zyYpHIOrk_Y

Post reply on HN