Top Interview Questions & Answers on Angular

In this post we are going to share some frequently asked questions of AngularJS, If you want to start career as an angular developer then this post is very useful for you. I am going to share basics and advance level of interview questions and answer of Angular.

1) What is AngularJS?

Answer:- AngularJS is a JavaScript framework used for creating single web page applications. It allows you to use HTML as your template language and enables you to extend HTML’s syntax to express your application’s components clearly.

Angular is a front-end or client-side framework which needs programming language like TypeScript ( developed by Microsoft ). Now, what does it mean when one says, “Angular is a client-side framework”? It means that it runs on the client-side or user’s browser and not on a Web Server . Angular is a product developed and maintained by the techie giant Google and has adopted the SPA

2) Who created Angular JS ?

Answer:-Initially it was developed by Misko Hevery and Adam Abrons. Currently it is being developed by Google.

3) Explain what are the key features of AngularJS ?

Answer:- The key features of AngularJS are

  • Scope
  • Controller
  • Model
  • View
  • Services
  • Data Binding
  • Directives
  • Filters
  • Testable
  • DOM Manipulation

4) Explain what is scope in AngularJS ?

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

5) What is services in AngularJS ?

Answer:-  Service is a simply JavaScript functions or singleton objects that are used for caring out specific task. It holds some business logic and these function can be called as controllers, directive, filters and so on.

6) What are the advantages of using Angular.js framework ?

Answer:- Advantages of AngularJS 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

7) What is Angular Material?

Answer:- It is an UI component library. Angular Material helps in creating attractive, consistent, modern and fully functional web pages as well as web applications. It does so while following modern web design principles, including browser portability and graceful degradation.

8) What is Data Binding? How many ways it can be done?

Answer:- Data Binding is the process that establishes the connection between the business logic and UI.

There are 3 ways to achieve data binding:

  1. Event Binding – Enables the application to respond to user input in the target environment
  2. Property Binding – Enables interpolation of values computed from application data into the HTML
  3. Two-way Binding – Changes made in the application state gets automatically reflected in the view and vice-versa. The ngModel directive is used for achieving this type of data binding.

9) What are directives in AngularJS?

Answer:- Directive is essentially  a function that executes when the Angular compiler finds it in the DOM. Directives are attributes that allow you to invent new HTML syntax, specific to your application.

Some of the most commonly used directives are ng-app, ng-controller and ng-repeat.

The different types of directives are:

  • Element directives
  • Attribute directives
  • CSS class directives
  • Comment directives

10) What are Controllers in AngularJS?

Answer:- Controller is a JavaScript object that contains attributes/properties and functions. A controller is defined using ng-controller directive.

Each controller accepts $scope as a parameter which refers to the applications/modules that the controller need to handle.

11) Explain what is injector in AngularJS?

Answer:- An injector is a service locator, used to retrieve object instance as defined by provider, instantiate types, invoke methods, and load modules.

12) What is ng-app, ng-init and ng-model?

Answer:-  The ngapp directive tells AngularJS that this is the root element of the AngularJS application. All AngularJS applications must have a root element. You can only have one ngapp directive in your HTML document.

  • ng-model : Binds HTML controls to application data.
  • ng-Controller : Attaches a controller class to view.
  • ng-repeat : Bind repeated data HTML elements. Its like a for loop.
  • ng-if : Bind HTML elements with condition.
  • ng-show : Used to show the HTML elements.
  • ng-hide : Used to hide the HTML elements.
  • ng-class : Used to assign CSS class.
  • ng-src : Used to pass the URL image etc.

13) What does a router.navigate do?

Answer:- When we want to route to a component we use router.navigate.  Syntax: this.router.navigate([‘/component_name’]);

14) Differentiate between ng-Class and ng-Style ?

ng-style is used to interpolate javascript object into style attribute, not css class.

Following directive will be translated to style=”color:red”

ng-class directive translates your object into class attribute.

Following will be translated to class=”deleted” when isDeleted variable is true.

15) Does Angular use the jQuery library?

Answer:- Yes, Angular can use jQuery if it’s present in the app when the application is being bootstrapped. If jQuery is not present in the script path, Angular falls back to its own implementation of the subset of jQuery that we call jQLite.

Add a Comment

Your email address will not be published. Required fields are marked *