1. What is data
binding in AngularJS? How does it relate to the MVC architecture?
In most templating systems, data binding is
unidirectional. When the model and template components are merged together, it
creates a view. However, the developer must write code to constantly
synchronize the model and the view. AngularJS uses two-way data binding, where
any changes to the view will automatically update the model and vice versa. The
view is more or less just a projection of the model, which greatly simplifies
things from the programmer’s perspective.
2. Explain why there are two “destroy” events associated with the termination of a scope in AngularJS.
The first $destroy is an AngularJS event
associated with components like controllers or link functions. The second is
actually a jqLite/jQuery event associated with the removal of a node, which may
occur without a scope teardown.
3. Explain the role
of $routeProvider in AngularJS.
The $routeProvider is used to configure roots
within an AngularJS application. It can be used to link a url with a
corresponding HTML page or template, and a controller (if applicable).
4. What are angular
prefixes $ and $$?
To prevent accidental name collisions within the
code, AngularJS prefixes the names of public objects with $ and the names of
private objects with $$.
It is recommended that $ or $$ prefix should not
be used in the code otherwise.
5. What
is ng-view in AngularJS?
The ng-view tag creates a placeholder where an
HTML or ng-template view can be placed based on the configuration.
Let’s take an example.
6. What is the
difference between one-way binding and two-way binding?
The main difference between
one-way binding and two-way binding is as follows.
·
In one-way binding, the scope variable in the HTML gets initialized with
the first value its model specifies.
·
In two-way binding, the scope variable will change its value whenever
the model gets a different value.
7.
Explain what is scope in AngularJS ?
Scope refers to the application model, it acts
like glue between application controller and the view. Scopes are
arranged in hierarchical structure and impersonate the DOM ( Document Object
Model) structure of the application. It can watch expressions and
propagate events.
8. Explain what is services in AngularJS ?
In AngularJS services are the singleton objects or
functions that are used for carrying out specific tasks. It holds some
business logic and these function can be called as controllers, directive,
filters and so on.
9. With options on page load how you can initialize a select box ?
You can initialize a select box
with options on page load by using ng-init directive
·
·
On = “! ! accounts” ng-init = “ loadData ( ) ”>
10.Explain what is string interpolation in Angular.js ?
In Angular.js the compiler during the compilation
process matches text and attributes using interpolate service to see if they
contains embedded expressions. As part of normal digest cycle these
expressions are updated and registered as watches.