Hacker News new | ask | show | jobs
by jackseviltwin 4848 days ago
(I'm the tech lead at CropUp)

I'm surprised how well AngularJS has worked for us.

Currently, we're using it for the shopping checkout page and also for the merchant dashboard. The dashboard is all driven by AngularJS (using $resource/$http api calls). The checkout page is more like Twitter, in that we preload data in the DOM when it's rendered, but there are API calls via AngularJS to create the order, check quantity, etc. These pages are actually served directly from our CDN.

As far as how it's worked for us. We've actually rewritten our dashboard and checkout page twice, and it look some getting used to on how to structure our controllers. Getting used to writing directives instead of using jQuery and doing DOM manipulation in our controllers also takes some discipline, because it's just way simpler to drop some selectors and event bindings/triggers in your controller.

The way AngularJS encourages you to keep any dom manipulation out of the controller and to think about reusable directives has really helped for readability and maintainability of the code base. We're consistently surprised how quickly we can implement features because of AngularJS. We've actually said, "Wow, that was easier than I was expecting" quite a few times.

However, there are some hurdles. $http doesn't support file uploads, the stable release doesn't support custom http headers with $resource, only one ngView, etc. That said, I still would not hesitate to recommend AngularJS.

2 comments

Did the limitation of having only one ng-view affect your project at all? I'm embarking on a new project using Angular and there are mixed opinions on the web. People that were shouting against it have come back saying that it's actually not so bad [1].

[1] https://groups.google.com/forum/?fromgroups=#!topic/angular/...

(Tech lead @ CropUp)

In the first iteration, we thought multiple ngViews would have been useful, but it didn't prevent us from achieving the design we wanted. You can use ngInclude to accomplish a similar effect, if you don't need the routing.

AngularUI seems to have a solution for nested views/routing here (https://github.com/angular-ui/ui-router). Although, I would think about your routes and the pieces of your web application and rethink whether you really need ngView. Using ngIncludes for pieces you want to reuse might make more sense.

edit: for clarity

It sure makes more sense, but you need to write boilerplate code to map URL state to ng-include changes/updates. It would be nice if it was out of the box.
I don't know the details of your app but maybe you should consider using ngView in the outer most container, then everything inside the container can pick the appropriate template via ngInclude. That's the path we took in our first iteration, this current iteration actually doesn't need nested/multiple ngViews.
ng-view is not simply a view (I think the name confuses most users), if you want multiple ng-views you will probably need more routers. Maybe there are some use cases for it, I just can't really think of one. You will pretty much split your application in N.

You really really really really want to keep those kind of things in directives.

Anyway, I read about it sometime ago on a github issue it is 'planned'.

(I'm a developer at CropUp)

Totally agree with Jack on this, I enjoy working with AngularJS. I think the learning curve could be made less steep with better docs. It would be great if they were moved to GitHub to make contributing easier.