Each angular application consist of one root scope but may have several child scopes. As child controllers and some directives create new child scopes, application can have multiple scopes. When new scopes are formed or created they are added as a children of their parent scope. Similar to DOM, they also creates a hierarchical structure.
Angular.js combines the functionalities of most of the 3rd party libraries, it supports individual functionalities required to develop HTML5 Apps. While Backbone.js do their jobs individually.
Advantages of using Angular.js as framework are:
► Supports two way data-binding
► Supports MVC pattern
► Support static template and angular template
► Can add custom directive
► Supports REST full services
► Supports form validations
► Support both client and server communication
► Support dependency injection
► Applying Animations
► Event Handlers
These are the ways that object uses to hold of its dependencies
► Typically using the new operator, dependency can be created.
► By referring to a global variable, dependency can be looked up.
► Dependency can be passed into where it is required.
DI or Dependency Injection is a software design pattern that deals with how code gets hold of its dependencies. In order to retrieve elements of the application which is required to be configured when module gets loaded , the operation "config" uses dependency injection.
► To observer model mutations scopes provide APIs ($watch).
► To propagate any model changes through the system into the view from outside of the Angular realm.
► A scope inherits properties from its parent scope, while providing access to shared model properties, scopes can be nested to isolate application components.
► Scope provides context against which expressions are evaluated.
ngModel adds these CSS classes to allow styling of form as well as control:
► ng- valid
► ng- invalid
For creating the directive, factory method is used. It is invoked only once, when compiler matches the directive for the first time. By using $injector.invoke the factory method is invoked.
It is used for registering DOM listeners as well as instance DOM manipulation. It is executed once the template has been cloned.