Angular JS Interview Question Set 2

Categories: Angular JS

 What is string interpolation in Angular.JS ?

In Angular.js, the compiler during the compilation process matches text and attributes. It uses interpolate service to see if they contain embedded expressions. As part of the normal digest cycle, these expressions are updated and registered as watches.


 What are the steps for the compilation process of HTML?

Compilation of HTML process occurs in the following ways


  1. Using the standard browser API, first, the HTML is parsed into DOM
  2. By using the call to the $compile () method, a compilation of the DOM is performed. The method traverses the DOM and matches the directives.
  3. Link the template with a scope by calling the linking function returned from the previous step


Explain directives and their types

During compilation process, when specific HTML function is triggered, it is referred to as directive. It is executed when the compiler encounters it in the DOM.

Different types of directives are:


1) Element directives

2) Attribute directives

3) CSS class directives

4) Comment directives.



 Explain the linking function and its types

Link combines the directives with a scope and produces a live view. For registering DOM listeners as well as for updating the DOM, link function is responsible. After the template is cloned, it is executed.

Pre-linking function: Pre-linking function is executed before the child elements are linked. It is not considered as a safe way for DOM transformation.

Post linking function: Post linking function is executed after the child elements are linked. It is safe to do DOM transformation by post-linking function



 Explain injector in AngularJS

An injector is a service locator. It is used to retrieve object instances as defined by provider, instantiate types, invoke methods, and load modules. There is a single injector per Angular application, it helps to lookup an object instance by its name.


What is the main difference between a link and compile in Angular.js?

Compile function: It is used for template DOM manipulation and collects all of the directives.

Link function: It is used for registering DOM listeners as well as for instance, DOM manipulation. It is executed once the template has been cloned.


 What is the factory function in AngularJS?

For creating the directive, factory method is used. It is invoked only once when the compiler matches the directive for the first time. By using $injector.invoke the factory method is invoked.


Explain the styling form that ngModel adds to CSS classes

NgModel adds these CSS classes to allow styling of form. Validation classes of AngularJS are:

  1. ng- valid
  2. ng- invalid
  3. ng-pristine
  4. ng-dirty


 What are the characteristics of “Scope”?

  1. To observer model mutations scopes provide APIs ($watch)
  2. To propagate any model changes through the system into the view from outside of the Angular realm
  3. A scope inherits properties from its parent scope, while providing access to shared model properties, scopes can be nested to isolate application components
  4. Scope provides context against which expressions are evaluated


What is DI (Dependency Injection) and how an object or function can get a hold of its dependencies?

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 the module gets loaded, the operation “config” uses dependency injection.

These are the ways that object uses to hold of its dependencies


  1. Typically using the new operator, dependency can be created
  2. By referring to a global variable, dependency can be looked up
  3. Dependency can be passed into where it is required

Top Blogs
Dependency Injection and AngularJS Routes Published at:- AngularJS Templates, Views, Models, Controllers Published at:- Integrating AngularJS with Other Frameworks Published at:- Testing AngularJS Applications in the IDE Published at:- End-to-End Testing with Protractor Published at:- AngularJS Views and Bootstrap Published at:- Adding a New Blog Controller Published at:- Adding a New Blog Template In Angular JS Published at:- Ways to Communicate with REST Services Published at:- Services and Business Logic and Handling User Authentication in Angular JS Published at:- Using Basic Authentication, Creating AngularJS Services, Holding User Credentials in Angular JS Published at:- AngularJS Security : why we are covering security in a book on AngularJS Published at:- MEAN Cloud and Mobile, Local Deployment and Installing Node.js, npm, and MongoDB in Angular Published at:- Angular Js MCQ Quiz (Multiple Choice Question and answers) for beginners Published at:- Angular 4 Questions - Angular 4 Quiz (MCQ) Published at:- AngularJS MCQ Quiz Questions with Answer Part 2 Published at:- AngularJS MCQ Quiz Questions with Answer Published at:- AngularJS MCQ Quiz Questions with Answer Published at:- Angular JS Interview Question Set 1 Published at:- Angular JS Interview Question Set 2 Published at:- Angular JS Interview Question Set 3 Published at:- Angular JS Interview Question Set 3 Published at:- Angular JS Interview Question Set 4 Published at:- Angular JS Interview Question Set 5 Published at:- Angular JS Interview Question Set 6 Published at:- Angular JS Interview Question Set 6 Published at:- Angular JS Interview Question Set 8 Published at:- Angular JS Interview Question Set 9 Published at:- Angular JS Interview Question Set 10 Published at:- Angular JS Interview Question Set 11 Published at:- Angular JS Interview Question Set 12 Published at:- React versus Angular What Would it be advisable for You Pick Published at:- 9 Advantages of Angular you really want to be aware if you have any desire to assemble Computerized Items Published at:- Top 20 Angular 10 Inquiries Questions and Answer Published at:- 9 Advantages of Angular you want to be aware to assemble Advanced Items Published at:- Top 5 Elements Angular Favored Decision for Web Improvement Published at:- Exploring the Latest Version of AngularJS: What's New and Exciting Published at:-
R4R.co.in Team
The content on R4R is created by expert teams.