Live data from Hacker News

Using AngularJS at Localytics

localytics.com

11–20 of 59 posts

Re: Using AngularJS at Localytics

#11

For those commenting on the poor quality of Angular's documentation (a complaint I share), check out John Lindquist's videos at http://egghead.io/ . They're not comprehensive, but John spends a great deal of time explaining the nuances of directives, especially isolate scopes and transclusion and his explanations are clear and intuitive. Prior to finding John's videos, I watched all of the "official" Angular videos w…

I second this. The videos are really great and are delivered in a way (short, to the point) that really helped me connect the dots in the areas where the Angular documentation wasn't sufficient. Especially the directive api, John does a great job there explaining isolate scope which was confusing to me for a while. Once you get it down you begin to realize how powerful Angular is.

Re: Using AngularJS at Localytics

#12
post #10

We used to write things like Then we realized it was bad to couple presentation and behavior, so we made our Javascript unobtrusive, keeping our templates clean. But now we’re back at it again, writing . Have we learned nothing? --- This seems like a good point that I can't refute - anyone?

[deleted]

Re: Using AngularJS at Localytics

#13
post #10

We used to write things like Then we realized it was bad to couple presentation and behavior, so we made our Javascript unobtrusive, keeping our templates clean. But now we’re back at it again, writing . Have we learned nothing? --- This seems like a good point that I can't refute - anyone?

The first one requires a global method. The angular one is a method that is tightly scoped and easy to test.

Re: Using AngularJS at Localytics

#14
post #10

We used to write things like Then we realized it was bad to couple presentation and behavior, so we made our Javascript unobtrusive, keeping our templates clean. But now we’re back at it again, writing . Have we learned nothing? --- This seems like a good point that I can't refute - anyone?

Honestly, there's not a huge amount of difference between

  Show Help
  
    $("#show-help-link").click(function() { showHelp(); } );
  
And

  Show Help
I mean, HTML has behavior in it. A link in itself is "behavior": when you click this tag, go to the page defined in the src attribute. So, as the author says, it's not really a bad thing that templates have behavior in them. In Ember.js, for example, you have an {{action}} handler that is essentially the same as ng-click - "run a function on the controller when this is clicked."

Re: Using AngularJS at Localytics

#15
post #10

We used to write things like Then we realized it was bad to couple presentation and behavior, so we made our Javascript unobtrusive, keeping our templates clean. But now we’re back at it again, writing . Have we learned nothing? --- This seems like a good point that I can't refute - anyone?

What solution are you comparing it to?

    
And the putting something like the following into a js file:

    $('#clickable-link).doSomething()
I find the declarative markup of a well-written angular app to be quite clean and easy to read, much more so than the alternatives.

Re: Using AngularJS at Localytics

#16
post #13
post #10

We used to write things like Then we realized it was bad to couple presentation and behavior, so we made our Javascript unobtrusive, keeping our templates clean. But now we’re back at it again, writing . Have we learned nothing? --- This seems like a good point that I can't refute - anyone?

The first one requires a global method. The angular one is a method that is tightly scoped and easy to test.

This too

Re: Using AngularJS at Localytics

#17

For those commenting on the poor quality of Angular's documentation (a complaint I share), check out John Lindquist's videos at http://egghead.io/ . They're not comprehensive, but John spends a great deal of time explaining the nuances of directives, especially isolate scopes and transclusion and his explanations are clear and intuitive. Prior to finding John's videos, I watched all of the "official" Angular videos w…

I agree. I've been going through his tutorials and they are great. Fire up sublime with node.js running as a simple http server and you can quickly follow along building simple apps that will get you up to speed.

Re: Using AngularJS at Localytics

#18
post #10

We used to write things like Then we realized it was bad to couple presentation and behavior, so we made our Javascript unobtrusive, keeping our templates clean. But now we’re back at it again, writing . Have we learned nothing? --- This seems like a good point that I can't refute - anyone?

Connecting presentation and behavior has to be done somewhere, otherwise your presentation do nothing and your behavior can't display. You shouldn't confuse "couple" with "connect".

Having a "onClickButtonA()" function call bound to a button whose id is "A", and then have the logic associated to the click on that button somewhere in the controller is a completely different thing than having "checkAccountBalanceAndSubmit()" directly in the HTML.

Angular remove 80% of explicit HTML/javascript conversation that were only there to dumbly synchronize input views and model. The rest is just really unavoidable.

Re: Using AngularJS at Localytics

#19
> Working with isolate scope and transclusion is tough, and Angular’s documentation on the subject doesn’t make it easier. We found that before jumping into writing an ambitious directive, it’s best to start by not writing a directive — just using normal templates and controllers — and then roll that code into a directive once you really figure out what your requirements are, or once you start repeating yourself..

Directives are, IMO, the most powerful parts of angular. They're also the most confusing. OP makes a great suggestion here that I'd recommend as well: Start with a normal template & controller then refactor into a directive later. In my experience, I've found that it's been useful to focus less on the DOM manipulation that needs to take place and more on the where the data collected needs to flow. In this way the directive just becomes the "glue" between a tiny area of the DOM and a parent controller and/or scope.

I guess you could liken them to the behavior/logic you'd have in a backbone view? That may be a stretch though. Powerful nonetheless.

Re: Using AngularJS at Localytics

#20
My experience with Angular.js was not that good though. May be I am real dumb, I can't see anyone with similar experience. I was totally frustrated with the amount of things I had to handle to bind my backend API. And also there were several issues like $scope.variables going wild. In short, it was a total mess in my case. I rather decided to roll out with Jquery instead. The code got totally cluttered I accept, but Angular.js frustrated to the point that 'elegant code' was least of my concerns, I just wanted to finish it somehow and run away and never look back.
Post reply on HN