Friday 14 November 2014

Angular JS - Basic Concepts

Model-View-View Model Pattern

AngularJS use extended version of the MVC pattern: the Model-View-ViewModel pattern, or MVVM for short.

Model layer --> application data and externally served via a REST API(Most Common Nowadays)
ViewModel   --> Proxy layer that converts business data into display data i.e data transformation
View --> Display layer i.e user interaction

Data Binding - Bi-Directional & Scope


Two way data binding is an integral part of Angular JS and based on scopes. A scope consists of the set of all variables and functions that are defined in a particular context(i.e) specific part of the DOM.AngularJS support two-way data binding only for variables or functions that are defined in a scope.The framework creates a root scope for an application. There can be multiple scopes defined and they can inherit from each other through prototypes and  form a hierarchy.

In Plain words,If Scope Y is inherited from Scope X, the context of Scope Y not only can you access the variables and functions defined in Y, but also the variables and functions defined in X and can be overridden.

IOC

Following the Spring IOC & Dependency Injection pattern, Angular JS brings those to client side.IOC - means your component need not worry about the dependencies instead the framework will resolve it. If you have no hard-coded dependencies anymore within an application component and have passed the responsibility of resolving dependencies to the environment, in the testing phase you can tell the framework to inject a mock object instead of an actual object.

End-to-End Testing

AngularJS has in built patterns for testing all its modules - Controllers,directives.Plus the IOC capability enhances the opportunity to provide mock implementation.


No comments:

Post a Comment