• +91 9723535972
  • info@interviewmaterial.com

Angular Interview Questions and Answers

Related Subjects

Angular Interview Questions and Answers

Question - 11 : - What is string interpolation in Angular.JS ?

Answer - 11 : - 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.

Question - 12 : - ) What are the steps for the compilation process of HTML?

Answer - 12 : - Compilation of HTML process occurs in the following ways • Using the standard browser API, first, the HTML is parsed into DOM • By using the call to the $compile () method, a compilation of the DOM is performed. The method traverses the DOM and matches the directives . • Link the template with a scope by calling the linking function returned from the previous step

Question - 13 : - ) Explain directives and their types

Answer - 13 : - 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.

Question - 14 : - Explain the linking function and its types

Answer - 14 : - 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

Question - 15 : - 15) Explain injector in AngularJS

Answer - 15 : - 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.

Question - 16 : - ) What is the main difference between a link and compile in Angular.js?

Answer - 16 : - • 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.

Question - 17 : - What is the factory function in AngularJS?

Answer - 17 : - 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.

Question - 18 : - Explain the styling form that ngModel adds to CSS classes

Answer - 18 : - 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

Question - 19 : - What are the characteristics of "Scope"?

Answer - 19 : - • 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

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

Answer - 20 : - 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 • 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


NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners