AngularJS Idioms and Tools

This page is my cheatsheet for AngularJS best practices. It is under frequent update.

Code Organization


* Organize your controllers in a parent-children hierarchy like this:

Inspired by Jim Lavin: AngularJS Services, Section Responsibilities of Controllers, Packt Publishing 2014.



Common JavaScript Coding Patterns





  • If you are not familiar with the pattern:
Then please check out the Ben Alman article about so-called "Immediately-Invoked Function Expression (IIFE)".

  • Object-oriented JavaScript using prototyping:
          My demo:
          Example by Jim Lavin from the book AngularJS Services:




Five Ways of Service at a Glance


  • constant: to define values that will not change over the course of your application
  • value: to define values that will not change over the course of your application
  • service: to define your services as a class and need to invoke the definition's constructor
  • factory: to define your services as an object instance and no need to invoke the definition's constructor
  • provider: to configure your service in a module's config method
Additional resource on this topic:



Data Management


...





AngularJS Style Guide





Productivity Tools


* Documenting your code:
    - JSDoc

(to be updated)




No comments:

Post a Comment