News for hackers. Stuff that matters.
Re:How AngularJS helped us ship our mobile site quicker - Pa... by nl on Monday August 13, 2012 @11:46AM (#4376416)
I love Angular.JS, and I appreciate seeing more stuff about it.

One thing I would like to see less of in introductory-type articles is Coffeescript.

I do understand the advantages of Coffeescript, but when one is trying to show off a framework like Angular.JS there is already quite a lot of non-obvious magic (eg: automatic dependency injection, the HTML compiler, etc etc) and introducing another thing that most people won't know well is a mistake IMHO.

If you like Coffeescript, then do a post about it, but mixing the two loses a lot of the audience.

Re:How AngularJS helped us ship our mobile site quicker - Pa... by msutherl on Monday August 13, 2012 @03:30PM (#4377668)
As somebody who learned CoffeeScript before JavaScript, I have to say I very much appreciate it when people use CoffeeScript in all manner of examples.
Re:How AngularJS helped us ship our mobile site quicker - Pa... by nl on Tuesday August 14, 2012 @12:17AM (#4379384)
As somebody who learned CoffeeScript before JavaScript

I think it is probably fair to say your situation is fairly unusual.

How did that happen?

Re:How AngularJS helped us ship our mobile site quicker - Pa... by joelhooks on Monday August 13, 2012 @01:22PM (#4376943)
I agree, it is interesting, but could definitely be another entire article. I've been having similar discussions around testing in this type of article. Angular has an excellent "testing story", with the end to end tests having a lot of baked in functionality. Unfortunately, most articles don't mention e2e or unit tests... ever. On some levels, I feel like testing should be included, even in beginner articles, but the cognitive load is already high...
Re:How AngularJS helped us ship our mobile site quicker - Pa... by Pherdnut on Monday August 13, 2012 @02:31PM (#4377299)
I don't really get the point of coffeescript at all tbh. JS is one of the most flexible languages in heavy use right now.
Re:How AngularJS helped us ship our mobile site quicker - Pa... by ebiester on Monday August 13, 2012 @06:02PM (#4378417)
Very simple: JS (module pattern, encapsulation) is verbose. CoffeeScript is more compact, allowing for more code on one page. I toy with going back to JS (I don't like everything about CS, especially with debugging and test tools in node development) but CS optimizes for the good parts of JS and ignores the parts I don't want to use anyway.
Re:How AngularJS helped us ship our mobile site quicker - Pa... by ceslami on Monday August 13, 2012 @07:27PM (#4378677)
As a guy who spends a lot of time writing JS, what are the good parts of JS that CS optimizes for, and what are the parts it ignores that you do not want to use?
Re:How AngularJS helped us ship our mobile site quicker - Pa... by cageface on Monday August 13, 2012 @11:04PM (#4379184)
It significantly reduces the symbol noise of JS. Typical JS is a dense forest of nested "function" expressions with a ton of (){} and it takes a lot of effort to fish out the logic.

CS strips out a lot of that and makes the intention of the code clearer.

Re:How AngularJS helped us ship our mobile site quicker - Pa... by aquark on Monday August 13, 2012 @10:52AM (#4376150)
Interesting -- but doesn't all that work to remove the 300ms delay mean make the site totally broken on any browser that doesn't generate touchstart/touchend/touchmove events?

I guess you could code around this by catching the click event and deciding if you have already handled it, but that is beginning to feel like a lot of fragile and browser specific code that certainly isn't application specific.

I tried to access your mobile site from my phone but it wants me to sign in with either Facebook or Twitter before showing anything, so that was a non-starter.

Re:How AngularJS helped us ship our mobile site quicker - Pa... by djb_hackernews on Monday August 13, 2012 @11:01AM (#4376196)
Fair point, but, I think people need to realize it's ok to only support certain browsers. Every project doesn't need to support every browser from the start. There are of course trade offs, but they mention they are targeting Safari on iOS, and this is ok.
Re:How AngularJS helped us ship our mobile site quicker - Pa... by pygy_ on Monday August 13, 2012 @11:14AM (#4376261)
> I tried to access your mobile site from my phone but it wants me to sign in with either Facebook or Twitter before showing anything, so that was a non-starter.

I created dummy accounts to that end. See https://twitter.com/loganloginski

Re:How AngularJS helped us ship our mobile site quicker - Pa... by ben_h on Monday August 13, 2012 @09:31AM (#4375764)
Great post. I didn't understand the role of controllers and directives but this explained them well with a thoughtful walk through.

The idea of wrapping distinct chunks of logic in separate directives that can then be sprinkled around the DOM declaratively is great.

In my view this is a welcome alternative; in my (maybe limited) experience, many other JS frameworks have you writing substantial amounts of glue code (i.e. bug-magnet code) to achieve comparable things.

Re:How AngularJS helped us ship our mobile site quicker - Pa... by markus2012 on Monday August 13, 2012 @12:16PM (#4376588)
AngularJS has been one of my pet projects recently.

I really like the idea of creating new modules and directives and I've created a few of them. However, after creating a number of modules and directives I started to think that it would be nice to have a central repo so I can quickly look for and find new directives.

The angular ui project doesn't fit the bill as I just want to import specific directives into my project.

Some way to determine directive dependencies would be nice too :-D

Re:How AngularJS helped us ship our mobile site quicker - Pa... by eknuth on Tuesday August 14, 2012 @12:41AM (#4379432)
I'm curious about why people jump on angular without even checking out knockoutjs. Knockout provides similar functionality with slightly less code. The demo/doc site is incredible.

I think it is also interesting that since backbone all the hot front end frameworks are of the model binding variety. Honestly when you do stuff like angular or knockout backbone just feels clunky.

I know that there are model binding plugins for backbone, but you still end up writing a bunch more code.

Re:How AngularJS helped us ship our mobile site quicker - Pa... by clivestaples on Tuesday August 14, 2012 @12:59AM (#4379484)
The things that sold me on AngularJS over Knockout were built-in routing and REST (via $resource). I feel like these things should be included in Knockout and by using third-party solutions or attempting to roll my own would have created more code/complexity than the AngularJS solution for my app.
Re:How AngularJS helped us ship our mobile site quicker - Pa... by MatthewPhillips on Monday August 13, 2012 @09:48AM (#4375821)
Custom attributes are a deal-breaker for me personally.
Re:How AngularJS helped us ship our mobile site quicker - Pa... by dhkl on Monday August 13, 2012 @11:28AM (#4376321)
Since 1.0.0rc1 that was released 5 months ago (1.0.0 went gold 2 months ago), the custom attributes used for by AngularJS can be turned into valid html5 attributes by prepending the "ng-*" AngularJS attributes with "data-". For example,

  <html ng-app>
can be turned into a valid attribute by making it

  <html data-ng-app>
I'm really glad to see how quickly the AngularJS team is addressing concerns like these. AngularJS is moving very fast, and there is a lot of room for improvements in documentation. But a quick check with the changelog would have showed that AngularJS supports the use of valid custom attributes for directives almost half a year ago.
Re:How AngularJS helped us ship our mobile site quicker - Pa... by geelen on Monday August 13, 2012 @09:56AM (#4375865)
Angular supports using data-attributes or using classes, I just prefer using custom attributes:

http://docs.angularjs.org/guide/directive

Re:How AngularJS helped us ship our mobile site quicker - Pa... by timriley on Monday August 13, 2012 @09:54AM (#4375848)
You actually have a fair bit of flexibility here, if that helps: https://github.com/angular/angular.js/blob/master/CHANGELOG....
Re:How AngularJS helped us ship our mobile site quicker - Pa... by riffraff on Monday August 13, 2012 @09:56AM (#4375863)
is there a concrete reason for not liking them, other than the content possibly being "non-valid"?

I also feel somewhat dirty when using custom attributes, and I admit I preferred xmli-sh HTML and namespaces a-la ng:attr.. but is there any practical difference?

Re:How AngularJS helped us ship our mobile site quicker - Pa... by libria on Monday August 13, 2012 @01:30PM (#4376979)
I think a lot of folks are afraid it's a slippery slope to this[1]: http://wekeroad.com/images/koouch.png

[1] http://wekeroad.com/2011/08/18/my-eyes-please-youre-killing-...

Re:How AngularJS helped us ship our mobile site quicker - Pa... by ehutch79 on Monday August 13, 2012 @11:09AM (#4376242)
they're not semantic. just like css classes are not semantic... also, ids are not semantic either.
Re:How AngularJS helped us ship our mobile site quicker - Pa... by pygy_ on Monday August 13, 2012 @11:38AM (#4376369)
... and neither is JavaScript.

We're dealing with applications here, not documents, and even in the latter case, your views regarding ids and classes are extreme.

Angular templates, more than just markup, are the skeleton of your application. The markup they generate is as semantic as you make it.

Re:How AngularJS helped us ship our mobile site quicker - Pa... by ehutch79 on Monday August 13, 2012 @10:42PM (#4379135)
the sarcasm tag is also not semantic
Re:How AngularJS helped us ship our mobile site quicker - Pa... by pygy_ on Tuesday August 14, 2012 @05:39AM (#4380083)
:-)

Actually, I hesitated before posting... I had ruled sarcasm out because purely snarky posts are usually frowned upon here, and your parent post was asking a legitimate question...

That being said, we obviously agree on the topic.

Re:How AngularJS helped us ship our mobile site quicker - Pa... by ehutch79 on Tuesday August 14, 2012 @05:06PM (#4383063)
poe's law?

In all seriousness though. That is kind of the correct answer to the parent. There's kind of this weird attachment to a whole bunch of weird 'best practices' in the design front. Many of them conflicting, many of them not well thought out. (There are some good ones coming out).

It's similar to twitter's bootstrap. Designers think it's horrible, if you believe the kind of blog with grey text on a grey background. But I can't believe people would recommend against it when they've seen the alternative.

Re:How AngularJS helped us ship our mobile site quicker - Pa... by pygy_ on Tuesday August 14, 2012 @06:31PM (#4383412)
True.

That's some cool stuff you make with your band, btw. What do you play?

Re:How AngularJS helped us ship our mobile site quicker - Pa... by windock on Monday August 13, 2012 @10:04AM (#4375911)
It is possible to prefix them with data- thus making it kinda valid html.
Re:How AngularJS helped us ship our mobile site quicker - Pa... by simonw on Monday August 13, 2012 @11:03AM (#4376207)
I held out for a while, but data- attributes really do make writing reusable JavaScript components SO much easier - if you use them responsibly I don't see any downside to them at all.
Re:How AngularJS helped us ship our mobile site quicker - Pa... by MatthewPhillips on Monday August 13, 2012 @11:54AM (#4376464)
I agree, I was talking about non data- custom attributes, but others have pointed out that you can use the data- versions as well, which is acceptable.
Re:How AngularJS helped us ship our mobile site quicker - Pa... by taude on Monday August 13, 2012 @10:41AM (#4376088)
In an era where any reasonably complex web application requires JavaScript, I'm less worried about the purity of the HTML. And with HTML5 "data-" attributes, I'm even less so.
Re:How AngularJS helped us ship our mobile site quicker - Pa... by kinleyd on Monday August 13, 2012 @11:57AM (#4376480)
Thanks, for me this was a great introduction to AngularJS. It looks good and pretty mature as well. I look forward to evaluating it in more depth.
Re:How AngularJS helped us ship our mobile site quicker - Pa... by edwinyzh on Monday August 13, 2012 @02:25PM (#4377263)
AngularJS is the ONLY web front end framework that makes me exciting, maybe because I'm from a Delphi background ;)