Takeaway from Advanced Tips & Tricks for using Angular JS by Simon Guest

I’m developing a web application with #AngularJS in a project, and since web development has never been of a great importance to me I’ve got a lot to learn. It was me to have picked AngularJS for the front-end, but right after I had chosen it, I found few other compelling web frameworks, like #React.

While I’m sure AngularJS will stay for a longer while in the project, I’m pursuing my understanding of React and where and how it can complement or even replace AngularJS.

Today I watched the slides Advanced Tips & Tricks for using Angular JS and here are the main points I wrote down to remember:

  • There’s more than controllers in AngularJS. Use services and directives early and often.
  • Directives:
    • make markup declarative
    • support templates
    • promote re-use
    • prevent lots of JavaScripts
  • slide 42: avoid console.log. Use $log instead.
  • AngularJS Batarang
  • UI Bootstrap – Bootstrap components written in pure AngularJS by the AngularUI Team
  • slide 53: Controllers should never refer to DOM elements
  • slide 53: Controllers should use services for business logic
  • $scope is glue between controller and model (accessed through services)
  • Services are singletons
  • Use watch collection to calculate required elements at the first invocation of a controller as follows:
    $scope.$watchCollection(‘items’, function(newItems) {
      for(var i = 0; i < newItems.length; i++) {
        newItems[i].price = getPrice(newItems[i].id);
      }
      $scope.items = newItems;
    });

Be Sociable, Share!
This entry was posted in Frameworks, JavaScript.

2 Responses to Takeaway from Advanced Tips & Tricks for using Angular JS by Simon Guest

  1. I did not get into React except from ClojureScript with Om, but isn’t it more focused on just reactive GUI components and data flows?

    Angular is much more “total”, it’s a complete client-side framework with DI, server communication, fancy backend/business logic with services etc. Data flow and GUI/DOM manipulation is just a fraction of its functionality.

  2. Daniel Kos says:

    I worked with Angular and recently with React. Angular is a waste of time IMO. React simplifies everything especially reasoning about data flow. It’s API is easy to remember and understand (try to write directive in angular – 4 types of scopes, strange chars of different meaning in terms of data binding (@, &, =) and much more.. And finally virtual dom – that’s a brilliant idea that should be implemented in the browser engine directly. I choose React for every new project. Maybe Angular 2.0 will be better but I very doubt it.

Leave a Reply

%d bloggers like this: