Live data from Hacker News

AngularJS Style Guide

gocardless.com

11–20 of 41 posts

Re: AngularJS Style Guide

#12
I find myself counter to the popular opinion on the use of controllerAs for mostly semantic reasons (IMO, a controller orchestrates services, $scope included, rather than containing data or references to data), though there are obvious and not-so-obvious tradeoffs with either choice.

That said, this style guide definitely has the strongest (almost convincing) argument I've seen for using controllerAs and does not have the inconsistencies I've found in other guides (`this` is not bound to `$scope` as a couple popular guides claim). Good stuff.

Re: AngularJS Style Guide

#13

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

Yeah that was a great talk, definitely worth watching for those looking for ways to improve the performance of their Angular apps. Do you know of any other videos like that? I've searched in the past but haven't come up with much (especially not for stuff relevant to latest versions of Angular)

Re: AngularJS Style Guide

#15

Earlier quoted context omitted.

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

Yeah that was a great talk, definitely worth watching for those looking for ways to improve the performance of their Angular apps. Do you know of any other videos like that? I've searched in the past but haven't come up with much (especially not for stuff relevant to latest versions of Angular)

I haven't really found any videos as comprehensive as this, just blog posts or videos that discuss one topic/strategy at a time. Outside of this video, there doesn't seem to be an authoritative or even comprehensive list of what can be done to speed up applications.

As to newer stuff, I believe Karl is specifically talking about 1.2 (might of been a release candidate or beta at the time) so his talk should be applicable to the newest stable version, and I've found that to be true so far.

As an aside, and I haven't objectively measured it or even really investigated it, it seems angular's 1.x stable versions aren't coming out as fast as they once did (it feels like 1.3 has been in rc/beta forever and 2.0 doesn't even seem to be out of the planning stages). So at this point I think 1.3 stable will be released in the next few months and hopefully they will have an updated talk on performance at the next ng-conf in March.

Re: AngularJS Style Guide

#16
post #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.

What does IIFE stand for? From your I'm guessing it's an immediately evaluating function - but I can't figure the initialism out

Re: AngularJS Style Guide

#17

Meh. NgAnnotate is way better than duplicating code. Be DRY, not pedantic.

Something we are looking to change. The duplication is pretty annoying, but we use AssetGraph-Builder for our production build, which uses ngmin, which doesn't play nice with ui-router. Also, now that 1.3 errors globally when you forget annotations, using NgAnnotate is much more of a no-brainer.

Re: AngularJS Style Guide

#19

Earlier quoted context omitted.

Yeah that was a great talk, definitely worth watching for those looking for ways to improve the performance of their Angular apps. Do you know of any other videos like that? I've searched in the past but haven't come up with much (especially not for stuff relevant to latest versions of Angular)

I haven't really found any videos as comprehensive as this, just blog posts or videos that discuss one topic/strategy at a time. Outside of this video, there doesn't seem to be an authoritative or even comprehensive list of what can be done to speed up applications. As to newer stuff, I believe Karl is specifically talking about 1.2 (might of been a release candidate or beta at the time) so his talk should be applica…

Yeah unfortunately 1.3 drops support for IE8 which sadly makes it inappropriate for our production app for the time being. Which is a shame because it looks to have a tonne of performance fixes and bind-once built in which would have been nice, to avoid using a 3rd party module.

Re: AngularJS Style Guide

#20
post #8

Earlier quoted context omitted.

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.

What does IIFE stand for? From your I'm guessing it's an immediately evaluating function - but I can't figure the initialism out

Correct.

http://en.wikipedia.org/wiki/Immediately-invoked_function_ex...

Post reply on HN