It aims to simplify both the development and the testing of such applications by providing a framework for client-side model–view–controller (MVC) and model–view–viewmodel (MVVM) architectures, along with components commonly used in rich Internet applications.
The framework adapts and extends traditional HTML to present dynamic content through two-way data-binding that allows for the automatic synchronization of models and views. As a result, AngularJS de-emphasizes explicit DOM manipulation with the goal of improving testability and performance.
- to decouple DOM (note1)manipulation from application logic. The difficulty of this is dramatically affected by the way the code is structured.
- to decouple the client side of an application from the server side. This allows development work to progress in parallel, and allows for reuse of both sides.
- to provide structure for the journey of building an application: from designing the UI, through writing the business logic, to testing
用 the MVC pattern, presentation, data, and logic components 分離
用 dependency injection, 減少 server side 負荷, 像用 view-dependent controllers, to client-side web applications.
- Scope = binding 這算是最重要的特色吧
“MVC" architecture, the scope forms the “Model", and all variables defined in the scope can be accessed by the “View" as well as the “Controller". The scope behaves as a glue and binds the “View" and the “Controller".
- Two-way data binding
- largely relieving the server backend of templating responsibilities.
Instead, templates are rendered in plain HTML according to data contained in a scope defined in the model.
$scopeservice in Angular detects changes to the model section and modifies HTML expressions in the view via a controller.
Likewise, any alterations to the view are reflected in the model.
This circumvents the need to actively manipulate the DOM and encourages bootstrapping and rapid prototyping of web applications.
AngularJS detects changes in models by comparing the current values with values stored earlier in a process of dirty-checking, unlike Ember.js and Backbone.js that trigger listeners when the model values are changed.