Browse Articles

Top 30 AngularJS Interview Questions and Answers 2022

04 Aug 2022

    AngularJS is a framework with a structural format for dynamic web applications. It will help you to use HTML as your template language and let you expand HTML’s syntax to articulate your application components briefly and clearly. Angular JS is an efficient framework which can create RIA (Rich Internet Application). 

    Angular JS is famous among developers as it provides developers with options to write client-side applications by using JavaScript in a clean MVC (Model View Controller) way. Taking AngularJS Training either online or offline is one of the smart things to do now as it has been developed by one of the biggest technology giants Google. If you still haven't used Angular, then you must wonder why people say JavaScript is the most flexible language in the world. It helps to develop a maintainable architecture that is easy to test at the client-end. So, don’t miss out on anything and place your footstep into the Angular field and prepare yourself with the help of the Angular Js Interview question answer Pdf file to crack the interview.

  1. Does AngularJS support MVC or MVVM pattern?

    AngularJS is an MVW framework where M stands for Model, V for the view and W for Whatever. It means you can follow either MVC or MVVM or MVP pattern since W stands for whatever you like.

  2. What is ViewModel?

    A ViewModel is an object that provides specific data and methods to maintain specific views. Basically, it is a $scope object which lives within your AngularJS app's controller. A ViewModel is associated with an HTML element with the ng-model and ng-bind directives.

  3. What is the Controller in AngularJS?

    The controller defines the actual behaviour of your app. It contains presentation logic for the view and connects the model to view with the help of $scope. A controller is associated with an HTML element with the ng-controller directive.

    Creating Controller

     <script type="text/javascript">
     //defining main controller
     app.controller('mainController', function ($scope) {
     //defining book viewmodel
     $ =
     id: 1,
     name: 'AngularJS Interview Questions and Answers',
     author: 'Shailendra Chauhan',

    Using Controller

     <div ng-controller="mainController">
     Id: <span ng-bind=""></span>
     <br />
     Name:<input type="text" ng-model="" />
     <br />
     Author: <input type="text" ng-model="" />
  4. How to share data or state between AngularJS controllers?

    There are multiple ways to share data or state between AngularJS controllers. The most commonly used ways are Scope, Service, Factory, and Providers.

  5. What are Templates in AngularJS?

    AngularJS templates are just plain old HTML that contains Angular-specific elements and attributes. AngularJS used these templates to show information from the model and controller.

    Creating an AngularJS template

     <html ng-app>
     <!-- body tag with ngController directive -->
     <body ng-controller="MyController">
     <input ng-model="txtName" value="shailendra"/>
     <!-- button tag with ng-click directive & string expression 'btnText' wrapped in "{{ }}" markup -->
     <button ng-click="changeName()">{{btnText}}</button> 
     <script src="angular.js"> 
  6. What is View in AngularJS?

    The view is responsible for presenting your model data to the end-user. A view contains HTML markup including AngularJS directives, attributes, and expression which AngularJS parse and compiled with HTML to generate the dynamic view.

  7. What are Expressions in AngularJS?

    AngularJS expressions are looks similar to JavaScript expressions, which you put inside the HTML templates by using double braces such as {{expression}}. AngularJS evaluates the expressions and dynamically insert the result to a web page. Like JavaScript expressions, AngularJS expressions can have literals, variables, and operators. There are some valid AngularJS expressions :

    {{ 1 + 2 }}
    {{ x + y }}
    {{ x == y }}
    {{ x = 2 }}
    {{ user.Id }}
  8. What is Databinding in AngularJS?

    Databinding is a mechanism to bind data or events with your HTML elements. Before Databinding, you have to manipulate or update the DOM elements and attributes to update model changes. AngularJS Databinding handles it nicely with the help of following the Data binding mechanism.

    1. One-Way Databinding

    2. Two-Way Databinding

  9. Explain Two-way Databinding in AngularJS?

    Two-way data binding is the most popular feature of AngularJS. It is used to sync the data between model and view i.e. any change in the model will update the view and vice versa. The two-way data-binding, you can use only with form input elements using ng-model directive. It can't be used with other elements like span, div, para, etc. which don't accept any input from the user.

    Two-way databinding feature in AngularJS

    Two-Way Databinding Example

     <div ng-controller="myCtrl">
     <label>Full Name (two-way binding): <input type="text" ng-model="name" /></label>
     <strong>Your Full Name (normal binding):</strong> {{name}}
     var app = angular.module('app', []);
     app.controller("myCtrl", function ($scope) {
     $ = "Mohan Chauhan"
  10. What is One-way Databinding in AngularJS?

    AngularJS 1.3 came with one new data-binding called as One-way data-binding. For one-way data-binding, double colon (::) is used as data-binding expression syntax.

    AngularJS one way databinding used for expression syntax

    One-Way data binding Example

     <div ng-controller="myCtrl"> 
     <strong>Your Full Name (one-way binding):</strong> {{::name}}<br />
     <strong>Your Full Name (normal binding):</strong> {{name}}
     var app = angular.module('app', []);
     app.controller("myCtrl", function ($scope) {
     $ = "Mohan Chauhan"
  11. What are Directives in AngularJS?

    AngularJS directives combine template markups (HTML attributes or elements, or CSS classes) and supporting JavaScript code to extend the power of existing HTML. The supporting JavaScript code defines the AngularJS template markup behaviour.

    In fact, AngularJS directives extend the HTML vocabulary by adding new attributes to manipulate HTML elements in an easy way. AngularJS supports various built-in directives like as ng-app, ng-controller, ng-repeat, ng-model, etc.

  12. What is the use of ng-app, ng-init and ng-model directives?

    The main use of ng-app, ng-init and ng-model directives areas follow :

    • ng-app: This directive is used to bootstrap the angular app.

    • ng-init: This directive is used to initialize data to AngularJS models.

    • ng-model :This directive is used to bind the data with form elements like input, select, text area etc.

  13. What are different ways to invoke a directive?

    There are four methods to invoke a directive in your angular app which is equivalent.

    Methods Syntax

     As an attribute - <span my-directive></span>
     As a class - <span class="my-directive: expression;"></span>
     As an element - <my-directive></my-directive>
     As a comment - <!-- directive: my-directive expression -->
  14. What are restrict options in the directive?

    The restrict option in an angular directive is used to specify how a directive will be invoked in your angular app i.e. as an attribute, class, element or comment. There are four valid options for restricting:

     'A' (Attribute) - <span my-directive></span>
     'C' (Class) - <span class="my-directive:expression;"></span>
     'E' (Element) - <my-directive></my-directive>
     'M' (Comment) - <!-- directive: my-directive expression -->
  15. What are the Filters in AngularJS?

    Filters are used to transform data before displaying it to the user. Filters are used in templates, controllers, services, and directives for data transformation. AngularJS supports various built-in filters like currency, date, number, orderby, lowercase, uppercase, etc. Even, you can create a custom filter.

    Filter Syntax

    {{ expression | filter }}

    Filter Example

     <script type="text/javascript">
    {{ 14 | currency }} //returns $14.00
  16. How to define Routing in AngularJS?

    Routing helps you to serve your web application app pages(views). The AngularJS service $routeProvider helps us to configure and handle routes. The $routeProvider service provides two methods when() and otherwise() to define the routes. The $routeProvider service is available in ngRoute module, so you have to its reference.

    Defining Route for your application

     <script type="text/javascript">
     var myApp = angular.module('myApp', ['ngRoute']);
     function ($routeProvider) {
     when('/products', { //route
     templateUrl: 'views/products.html',
     controller: 'productController'
     when('/product/:productId', { //route with parameter
     templateUrl: 'views/product.html',
     controller: 'productController'
     otherwise({ //default route
     redirectTo: '/index'
  17. What is the AngularUI router and how it is different from ngRoute?

    The UI-Router is developed by AngularUI team for configuring and managing routes in an AngularJS application. It is based upon state rather than URL, so it changes an angular app views based on the state of the application. The UI-router helps you to create nested views, use multiple views on the same page, have multiple views that control a single view, and more. To use it you need to include reference of the ui-router.js file into your angular app.

  18. How Does Dependency Injection work in AngularJS?

    Dependency Injection (DI) is a programming technique that allows you to build loosely coupled software components. AngularJS has a built-in dependency injection mechanism to inject dependencies into different types of AngularJS components. There are following three ways of injecting dependencies into your code :

    Implicitly from the function parameter names

     <script type="text/javascript">
     function MyController($scope, greeter) {
     // ...

    Using the $inject property annotation

     <script type="text/javascript">
     var MyController = function(renamed$scope, renamedGreeter) {
     // ...
     MyController['$inject'] = ['$scope', 'greeter'];

    Using the inline array annotation

     <script type="text/javascript">
     someModule.factory('greeter', ['$window', function (renamed$window) {
     // ...
  19. What is Service in AngularJS?

    A service is a singleton object which contains business logic for your AngularJS application. Service is also used to share state or data across your angular application components. A service can be injected into controllers, filters, directives. AngularJS offers several built-in services (like $http, $provide, $resource, $window, $parse) which always start with $ sign.

  20. What are different methods to create a service in AngularJS?

    There are five methods to create a service in AngulaJS as given below :

    • Service

    • Factory

    • Provider

    • Value

    • Constant

  21. What is $scope in AngularJS?

    In AngularJS, $scope is an object that refers to an application model. In simple terms, it is a special JavaScript object which binds the view (DOM element) and the controller. The $scope object helps to access model data in the controller. Since the AngularJS supports MV* pattern, this object turns out to be the model of MV*.

    It is important to note that both controller and View gain access to the scope object. Moreover, it can be utilized for communication between controller and view. Both functions and data are present in this object. Each AngularJS application contains a $rootScope which is the topmost scope made on the DOM element that comprises the ng-app directive. Furthermore, it can watch expressions and transmit events.

  22. What is SPA (Single page application) in AngularJS?

    Single-Page Applications (SPAs) are nothing but web applications that load a single HTML page and update that particular page dynamically whenever the user interacts with that app. Moreover, SPAs make use of HTML and AJAX to make responsive and fluid web apps; no need for continuous page reloads. But this implies that a lot of work takes place on the client-side, within JavaScript. When you undergo Angular Training, you may get the exact meaning of SPA.

  23. Why are we using AngularJS?

    It becomes clear on the usefulness of AngularJS when you complete an angular js training in hyderabad. We already know that AngularJS works on the MV* pattern. (where * can be C(controller) or VM (view model)). It enables us to create testable, well-structured, and maintainable front-end applications.

    Here are the reasons for using AngularJS: 

    1. It assists anyone to better organize web applications or web apps.
    2. It also assists to make well-organized and responsive web applications that are more readable and expansive.
    3. Two way data binding approach is used. This approach assists us so that any modifications in the model would be updated view and vice-versa; no need to make any modification on events or DOM.
    4. AngularJS supports services and dependency injection that we can effortlessly inject into a controller and offers some utility code according to our requirements.
    5. AngularJS allows you to make your own directive that allows reusable components to be utilized as per your requirement.
  24. Why is it necessary to use AngularJS Global Object services?

    The key reason that AngularJS encompasses these services is to simplify testing. A significant aspect of unit testing is the requirement to a tiny code and ten test its behavior in absence of testing components on which it depends. Ultimately, it creates a focused test. Furthermore, the DOM API renders functionality via global objects like windows and documents.

    Such objects make it difficult to isolate code for unit testing and there is no need for testing how the browser executes its global objects. The use of services like $document permits AngularJS code to be written without using the DOM API global objects directly. Furthermore, it enables the use of AngularJS testing services to organize explicit test scenarios.

  25. What is the Provider Method in AngularJS?

    The Module.provider method enables you to employ enhanced control on the manner that a service object is made or configured. In this method, the arguments are the name of the service which is being defined and another argument is a factory function. Essentially, the factory function is needed to return a provider object which defines a method known as $get. This, in turn, is needed to return the service object. .

    Whenever the service is required, AngularJS will call the factory method to obtain the provider object and afterward calls the $get method to obtain the service object. Implementation of the provider method does not modify the manner in which those services are used. This also suggests that the user need not make any modifications to the directive or controller in the example.

  26. What is event handling in AngularJS?

    It is important to learn event handling when you Learn Angular Step by Step. For creating advanced AngularJS applications like user interaction forms, it becomes necessary to deal with DOM events such as moves, mouse clicks, change events keyboard presses, etc.

    Here are some of the prominent events in AngularJS:.

    • ng-click
    • ng-dbl-click
    • ng-mouseup
    • ng-mousedown
    • ng-mouseenter
    • ng-mouseleave
    • ng-mouseover
    • ng-mousemove
    • ng-keydown
    • ng-keyup
    • ng-keypress
    • ng-change
  27. Why do developers choose AngularJS?

    AngularJS is an open-source web application framework that is expansively used in creating extremely robust and scalable kinds of Single Page Applications (SPA). Essentially, SPAs are web applications or websites that cover a single web page, rendering an immersive and seamless user experience. This framework is written in JavaScript. It permits the use of HTML as a template language. Furthermore, it assists in building intuitive web applications. Therefore, web developers gain the option to create client-side applications..

  28. What are the attributes you can use when creating new AngularJS Directives?

    Here is the list of attributes you can use when creating a new AngularJS Directives:

    • Template
    • TemplateUrl
    • Restrict
    • Replace
    • Transclude
    • Controller
    • Scope
    • Require
    • Compile
    • Link
  29. Explain what is injector in AngularJS?

    The $injector service is accountable for deciding the dependencies that a particular function declares and then it works on solving those dependencies. This service is present in the core of the AngularJS library. It is important to note that there is hardly ever a need to directly work with it. However, it can prove to be useful for understanding and manipulating how AngularJS functions. These types of customizations need to be considered meticulously and tested properly.

    The Angular Tutorial gives you an understanding of the injector in AngularJS. If you are thinking about how to become an angular developer, you can follow the tutorial and clear all fundamental aspects.

  30. What are Constants in AngularJS?

    Constant are similar to services in AngularJS wherein we can define our global data. The "constant" keyword is used to declare it. The way we define app-keys in Web.Config file for ASP.NET application that later on can be used anywhere in the application, similarly we can also globally declare constant data in AngularJS which can be utilized all through the application.

    It is possible to inject Constant everywhere in service or controller just like any other dependency. For the creation of Constant dependency in an Angular application, AngularJS utilizes Singleton structure. Therefore, using the Constant allows you to create your Config.js file and you can inject it anywhere in an application.


I personally belive these questions and answers have helped you in your interview preparation along with learning interview questions & answers. you should learn from Dot Net Tricks Angular js online traning programs which are freely available. our Angularjs training enables you to brush-up your concepts by refering various angular js training videos.

These interview questions have been taken from our new released eBook AngularJS Interview Questions & Answers. This book contains more than 100+ AngularJS interview questions.

This book has been written with the intent of preparing yourself for AngularJS interview with a solid foundation on AngularJS in a short time. It's would be equally helpful in recalling Angular js traning hyderbad to learn by building projects to crack your AngularJS Interview.

Buy this eBook at a Discounted Price!

AngularJS Interview Questions & Answers eBook

Learn to Crack Your Technical Interview

Accept cookies & close this