(draft) AngularJS Architecture
I am really interested in the architecture of AngularJS applications and in this post I am just trying to settle a view of the subject for myself.
The article about Angular architecture that inspired me to write this post: “Angular.js Large Scale Architecture and StarCraft“. I will be using this one as the first source for this post.
The most interesting implementation of Angular app I ever met was this one with RequireJS: “Thomas Burleson Angular and RequireJS“. I would like to create a yeoman generator for this pattern (yeoman).
Unique features: Directives and DI (Dependency Injection)
Key points: DI, Directives, Testing oriented.
Modularity: “features are in a take-it-or-leave-it single package”. You incur the download price for every piece whether you use it or not.
- Services (application brain): Logic + State
- Controllers (mini brains – less capable, and responsible of view specific tasks): Logic + State
- Views (display, user interaction): Template + Directives + Filters
- is more like a View Model or Presentation Model.
- holds “scope” object responsible for:
- view data
- presentation state
- reaction behaviour
- sets initial state values.
- is a glue between view and services.
- knows nothing about the view (Separation of Concerns) -> testing and reuse!
- No imperative logic allowed.
“Angular.js isn’t really MVC. Its controllers are actually presentation models, its views are plain templates and it’s models… well.. there aren’t any, they are just plain old objects and arrays.”
“When you want to extend your application cross cutting capabilities, you add a service, a filter or a directive. And when you want to add another screen or page specific view, you can add a template/controller pair.”
- (?) Declarative (present and react).
DI: Providers and Injectors
– blog title idea