80+ AngularJS Interview Questions

AngularJS is a JavaScript framework that is used for making rich, extensible web applications. It runs on plain JavaScript and HTML, so you don't need any other dependencies to make it work. Below are some basic facts about AngularJS that must an AngularJs Developer know before appearing in AngularJs Interview

  • Based On: MVC and MVVM design pattern. Design Patterns in programming languages are used write reusable and maintainable code for commonly occurring problems in Software Engineering.
  • Written In: AngularJs 1.x is written in Javascript. It one of the most popular programming language on the web for creating interactive and scalable front end and server applications.
  • Supported Features: AngularJS supports features like bundling codes in modules, Dependency Injection, Routing, two-way data binding, services that help developers to write clean and reactive, user-friendly applications using Javascript.
  • Best Suited for: AngularJs is best suited for creating Single Page Applications and admin backends
  • Maintained By: It is maintained by Google Inc.
  • Licensed: Angular JS is licensed under MIT License that means anyone can modify the source code and republish it.

Top 80 AngularJS Interview Questions and Answers.

  • Q1.

    What is Angular JS?

    AngularJS is a JavaScript framework that is used for making rich, extensible web applications. It runs on plain JavaScript and HTML, so you don’t need any other dependencies to make it work.AngularJS is perfect for Single Page Applications (SPA). It is basically used for binding JavaScript objects with HTML UI elements.

  • Q2.

    Explain the architecture of AngularJS?

    AngularJS is architecture on 3 components. They are

    • The Template (View)
    • The Scope (Model)
    • The Controller (Controller)

    AngularJS extends HTML attributes with Directives and binds data to HTML with Expressions.

  • Q3.

    What is the Template in AngularJS?

    The template is the HTML portion of the angular app. It is exactly like a static HTML page, except that templates contain additional syntax which allows data to be injected in it in order to provide a customized user experience.

  • Q4.

    What is the scope in AngularJS?

    The scope is the object that represents the “model” of your application. It contains fields that store data which is presented to the user via the template, as well as functions which can be called when the user performs certain actions such as clicking a button.

  • Q5.

    What is the controller in AngularJS?

    The controller is a function which generally takes an empty scope object as a parameter and adds to it the fields and functions that will be later exposed to the user via the view.

  • Q6.

    Explain Directives in AngularJs?

    AngularJS directives are extended HTML attributes with the prefix ng-
    The 3 main directives of angular js are

    • ng-app:- directive is used to flag the HTML element that Angular should consider to be the root element of our application. Angular uses spinal-case for its custom attributes and camelCase for the corresponding directives which implement them.
    • ng-model:- directive allows us to bind values of HTML controls (input, select, textarea) to application data. When using ngModel, not only change in the scope reflected in the view, but changes in the view are reflected back into the scope.
    • ng-bind:- directive binds application modal data to the HTML view.
  • Q7.

    List some tools for testing AngularJS applications?

    For testing AngularJS applications there are certain tools that you should use that will make testing much easier to set up and run.


    Karma is a JavaScript command line tool that can be used to spawn a web server which loads your application’s source code and executes your tests. You can configure Karma to run against a number of browsers, which is useful for being confident that your application works on all browsers you need to support. Karma is executed on the command line and will display the results of your tests on the command line once they have run in the browser.

    Karma is a NodeJS application and should be installed through NPM/YARN. Full installation instructions are available on the Karma website.


    Jasmine is a behavior-driven development framework for JavaScript that has become the most popular choice for testing AngularJS applications. Jasmine provides functions to help with structuring your tests and also making assertions. As your tests grow, keeping them well structured and documented is vital, and Jasmine helps achieve this.

    Jasmine comes with a number of matches that help you make a variety of assertions. You should read the Jasmine documentation to see what they are. To use Jasmine with Karma, we use the karma-jasmine test runner.


    AngularJS also provides the ngMock module, which provides mocking for your tests. This is used to inject and mock AngularJS services within unit tests. In addition, it is able to extend other modules so they are synchronous. Having tests synchronous keeps them much cleaner and easier to work with. One of the most useful parts of ngMock is $httpBackend, which lets us mock XHR requests in tests and return sample data instead.


  • Q8.

    How do you share data between controllers in AngularJs?

    We can share data by creating a service, Services are easiest, fastest and cleaner way to share data between controllers in AngularJs.
    There are also other ways to share data between controllers, they are

    • Using Events
    • $parent, nextSibling, controllerAs
    • Using the $rootScope
  • Q9.

    Explain AngularJS digest cycle?

    AngularJS digest cycle is the process behind Angular JS data binding.
    In each digest cycle, Angular compares the old and the new version of the scope model values. The digest cycle is triggered automatically. We can also use $apply() if we want to trigger the digest cycle manually.

  • Q10.

    What is internationalization in Angularjs?

    Internationalization is a way to show locale-specific information on a website.It is used to create multilingual language websites.

  • Q11.

    Difference between AngularJS and JavaScript Expressions?

    Below are some major difference between AngularJS and JavaScript Expressions

    • Both can contain literals, operators, and variables.
    • AngularJS expressions can be written in HTML but JavaScript expressions are not.
    • AngularJS expressions do not support conditionals, loops, and exceptions, while JavaScript expressions do.
    • AngularJS expressions support filters, while JavaScript expressions do not.
  • Q12.

    Explain basic steps to set up an Angular app?

    • Create an angular.module
    • Assign a controller to the module
    • Link your module to HTML with ng-app
    • Link the controller to HTML with ng-controller directive
  • Q13.

    What are Angular Modules?

    Angular Modules are place where we write code of our Angular application.Writing Modules makes our code more maintainable, testable, and readable. All dependencies for our app are defined in modules.

  • Q14.

    Explain Directive scopes?

    There are three types of directive scopes available in Angular.

    • Parent Scope: is default scope
    • Child Scope:  If the properties and functions you set on the scope are not relevant to other directives and the parent, you should probably create a new child scope.
    • Isolated Scope: Isolated Scope is used if the directive you are going to build is self-contained and reusable. Does not inherit from parent scope, used for private/internal use.
  • Q15.

    How to isolate a directive’s Scope in Angular?

    You can isolate a directive’s Scope by passing an object to the scope option of directive.
    This tells the directive to keep scope inside of itself and not to inherit or share with other scopes.

  • Q16.

    What is the difference between one-way binding and two-way binding ?

    In One-Way data binding, view (UI part) not updates automatically when data model changed. We need to write custom code to make it updated every time.
    ng-bind has one-way data binding.

    While in two way binding scope variable will change it’s value every time its data model changed is assigned to a different value.

  • Q17.

    How would you make an Angular service return a promise? Write a code snippet as an example

    To add promise functionality to a service, we inject the “$q” dependency in the service, and then use it like so:

    angular.factory('testService', function($q){
    return {
    getName: function(){
    var deferred = $q.defer();
    //API call here that returns data
    return deferred.promise;

    The $q library is a helper provider that implements promises and deferred objects to enable asynchronous functionality

    Source: https://docs.angularjs.org/api/ng/service/$q

  • Q18.

    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).

  • Q19.

    Explain how does Angular implement two-way binding?

    Data-binding in Angular apps is the automatic synchronization of data between the model and view components. The way that Angular implements data-binding lets you treat the model as the single-source-of-truth in your application. The view is a projection of the model at all times. When the model changes, the view reflects the change and vice versa.

  • Q20.

    What is dependency injection and how does it work?

    AngularJS was designed to highlight the power of dependency injection, a software design pattern that places an emphasis on giving components their dependencies instead of hardcoding them within the component. For example, if you had a controller that needed to access a list of customers, you would store the actual list of customers in a service that can be injected into the controller instead of hardcoding the list of customers into the code of the controller itself. In AngularJS you can inject values, factories, services, providers, and constants.

  • Q21.

    What is $rootscope? How is it different from the scope?

    In Angular JS $rootscope and $scope both are an object which is used for sharing data from the controller to view.
    The main difference between $rootscope and $scope is that $rootscope is available globally to across all the controllers whereas $scope is available only in controllers that have created it along with its children controllers.

  • Q22.

    What is the difference between $scope and scope?

    In Angular js $scope is used whenever we have to use dependency injection (D.I) whereas as the scope is used for directive linking.

  • Q23.

    What are Angular Expressions?

    Angular js Expression is JavaScript alike code snippets used to bind expression data in view or HTML. Angular expressions are written inside two curly braces.


  • Q24.

    List the major browsers Supported by Angular js?

    Below are some major browsers supported by Angular js

    • Mozilla Firefox
    • Google Chrome
    • Microsft Edge
    • IE 10,11
    • IE Mobile,
    • Safari, iOS
    • Android: Nougat (7.0) Marshmallow (6.0)
  • Q25.

    How to enable HTML5 mode in Angular 1.x?

    html5Mode method of $locationProvider module is used to enable HTML5 mode in Angular 1.x. For creating pretty URLs and removing # from URLs html5Mode need to true.

    Enabling html5Mode to true in Angular 1.x.

    angular.module('myApp', [])
        .config(function($routeProvider, $locationProvider) {
                .when('/', {
                    templateUrl : 'partials/home.html',
                    controller : mainController
            // use the HTML5 History API
  • Q26.

    List some of the built-in validators in Angular JS?

    Angular js supports all standard HTML5 attributes to validate input.Below are few built-in validators in Angular js.

    • required
    • min
    • max
    • type=”number” OR type=”email”
  • Q27.

    What is Angular’s prefixes $ and $$?

    Angular uses these prefixes to prevent accidental code collision with users code.
    $ prefix is used with public objects whereas $$ prefix is used with a private object.

  • Q28.

    What are directives? How to create and use custom Directive in Angular js.

    In angular Directives are used to extend the attributes of Html elements.
    Creating custom directive in Angular js.
    Angular js Directives are restricted to element and attribute and created using a directive function.Here is sample code to create a directive in Angular js.

    var app = angular.module("myApp", []);
    app.controller('AppController', function($scope) {
        var users=[];
        var user1={};
        var user2={};
    app.directive('user', function() {
        //define the directive object
        var directive = {};
        //restrict = E, implies that directive is Element directive
        directive.restrict = 'E';
        //element will be replaced by this text/html
        directive.template = "First Name: {{user.firstName}} , Last Name: {{user.lastName}}";
        var linkFunction = function($scope, element, attributes) {
            element.css("background-color", "#e1e1e1");
        return directive;

    As Above directive is restricted to Element directive, so you can use this directive as an element only.

    <div ng-app="app">
     <h1>Custom Directive Demo</h1>
     <div ng-controller="UserController">
     <div ng-repeat="user in users">
  • Q29.

    How to access parent scope from child controller in Angular JS?

    In angular there is a scope variable called $parent (i.e. $scope.$parent). $parent is used to access parent scope from child controller in Angular JS.

    <div ng-controller="ParentCtrl">
        <h1>{{ name }}</h1>
        <p>{{ address }}</p>
        <div ng-controller="ChildCtrl">
            <h1>{{ title }}</h1>
            <input type="text" ng-model="$parent.address" />
  • Q30.

    How to do email and Phone no. validation in Angular JS?

    Angular form validation and ng-pattern directive can be used to validate the email and phone number in Angular JS.

  • Q32.

    How can you get URL parameters in Controller?

    The RouteProvider and the RouteParams can be used to get the URL parameters in the controller.
    As the route wires up the URL to the controller and RouteParams can be passed to the controller to get the URL parameters.

  • Q33.

    How to enable caching in Angular 1.x?

    Caching can be enabled by setting the config.cache value or the default cache value to TRUE or to a cache object that is created with $cacheFactory.
    In case you want to cache all the responses, then you can set the default cache value to TRUE.
    And, if you want to cache a specific response, then you can set the config.cache value to TRUE.

  • Q34.

    Explain the use of Ng-If, Ng-Switch, And Ng-Repeat directives?

    ng-if – This directive removes a portion of the DOM tree, which is based on the expression.
    In case the expression is assigned to ng-if, it evaluates to a false value, and then the element is deleted from the DOM tree, or else a clone of the element is reinserted into the DOM.
    ng-switch – This directive is used based on a scope expression to conditionally swap DOM structure on the template.
    The ng-switch default directive will be preserved at the specific location in a template.
    ng-repeat – This directive is used to instantiate the template once per item from a collection.
    Each template which is instantiated gets its own scope where the given loop variable is set to the current collection of item.

  • Q35.

    How to change start and end symbols used for AngularJS expressions?

    Passing the $interpolateprovider in the config can help us change the start and end symbols used in our Angular JS expressions.

  • Q36.

    List some difference between Angularjs and Angular 2?

    Difference between AngularJS and Angular 2
    Angular js or Angular 1.x is based on MVC ArchitectureAngular 2 is based on service/ components
    Javascript is used to write applications in Angular js.Typescript (superset of javascript) is used to write application in Angular2.
    Controller are used to write logics and interact with Model and view.In Angular 2 Controllers are totally elminated and Components take its place.
    Angular 1 is created for developing Single page web-applications.In Angular 2 can used for developing native applications for mobile platform like React Native as well interative
    web applications.
    Angularjs is easy to setup, you just need to include angular.js library to start.Angular 2 is dependent on other modules/ package.It give little brainstrom to install and run Angular 2.
    In Angularjs ng-app directive is used bootstrap the app.ng-app is removed in Angular 2. You need to call Angular2 bootstrap method to bootstrap your application.
  • Q37.

    How to validate an URL in Angular JS?

    Adding the regex directly to the ng pattern to the attribute can help you validate the URL in Angular JS.

  • Q38.

    What is the use of $locale service in Angular JS?

    locale service provides with the localization rules for Angular JS components.

  • Q39.

    What is transclusion in Angular JS?

    The transclusion in Angular JS will allow you to move the original children of a directive to a specific location inside a new template.The ng directive marks the insertion point for the transcluded DOM of the very near parent directive that uses transclusion.
    ng-transclude or ng-transclude-slot attribute directives are used for transclusion in Angular JS.

  • Q40.

    What is a locale ID in Angular JS?

  • Q41.

    What is the difference between a stateful and stateless component in AngularJs?

  • Q42.

    List some methods supported by $http service?

  • Q43.

    What is “track by” in AngularJS and how does it work?

  • Q44.

    Explain $templateCache in Angular Js?

  • Q45.

    What is the difference between a unit and end-to-end (e2e) test?

  • Q46.

    Explain .config() and .run() methods in AngularJS?

  • Q47.

    What is a Mocked Service in Angular Js? How to use it?

  • Q48.

    How to implement caching in Angular 1.x?

  • Q49.

    What are Compile, Pre, and Post linking in AngularJS?

  • Q50.

    How to use $scope.$watch and $scope.$apply in AngularJS?

  • Q51.

    How to use Multiple ng-app within a page in AngularJS?

  • Q52.

    How to set focus on the input field in Angular 1.x?

  • Q53.

    Write a code to upload an image in Angular js?

  • Q54.

    How to send an Http post request in Angular js?

  • Q55.

    What is the difference between ‘this’ vs $scope in AngularJS controllers?

  • Q56.

    How $location is different from window.location?

  • Q57.

    What is the use of ng-cloak directive?

  • Q58.

    How to do Animation in AngularJS?

  • Q59.

    How to format a date in Angular js?

  • Q60.

    What is $emit, $broadcast and $on in AngularJS?

    $broadcast, $emit, and $on are services in Angular Js. Below we have listed why they are used In Angular JS.

    $broadcast(): $broadcast() service of Angular is used to propagate the event to all of his child controllers and it’s registered parent $rootscope.scope listeners.

    $rootScope.$broadcast('SummaryEvent', {
                    priority: priority               

    $on(): AngularJS $on() service is used to listen any type of event raised by $broadcast and $emit.

    $scope.$on(''SummaryEvent'', function (event, args) {

    $emit: $emit is similar to $broadcast service but it is used to propagate the event to upwards through the scope hierarchy and notify to the registered $rootScope.Scope listeners.

  • Q61.

    What are scopeless controller? why to use them?

  • Q62.

    What is Isolate Scope and why it is required?

  • Q63.

    What is the difference between $evalAsync and $timeout?

  • Q64.

    How to disable right click event in Angular js?

  • Q65.

    What is a provider in Angular JS?

  • Q66.

    Explain Bootstrapping in Angular Js?

  • Q67.

    How Angular.js is different from Jquery?

  • Q68.

    List and explain different types of directive available in Angular Js?

  • Q69.

    What is a dynamic route in Angular js and how do you implement it?

  • Q70.

    What is different between ng routing and UI routing?

  • Q71.

    Explain UI Routing in AngularJS?

  • Q72.

    Explain Routing in Angular Js?

    Routing is one the core feature of AngularJs Framework that is useful in building a single page web application with multiple views. In Angular ngRoute Module is used to implement Routing. ngView,$routeProvider,$route and $routeParams are different components of the ngRoute Module that helps to configure and mapping Url to views.

  • Q73.

    Explain Event in Angular js. List some events you have worked in AngularJs?

  • Q74.

    How to create a service in Angular js?

  • Q75.

    How to disable a control or element in Angular js?

  • Q76.

    Explain ng-include directive?

  • Q77.

    How to hide or show a div in Angular js?

  • Q78.

    How to create a service using Factory?

  • Q79.

    List some inbuilt services in AngularJs ?

    There are 30 inbuilt services in AngularJs. Below are few most used services in AngularJs.

    • $location
    • $scope
    • $http
    • $timeout
    • $interval
    • $window
  • Q80.

    What are filters in AngularJS ? Can you list some?

  • Q81.

    List some Cons or disadvantages of using AngularJS?

  • Q82.

    Explain DDO in AngularJs?

    DDO Stands for Directive Definition Object. DDO is used while creating a custom directive in AngularJs.

  • Q83.

    What is an interceptor in Angular? Why it is used?

    An interceptor is a middleware code in AngularJs where all the $http requests go through. It is attached with $httpProvider service and able to intercept request and response objects. Interceptor Middleware is useful for error handling, authentication and other filters you want to apply on request and response.

  • Q84.

    Explain the functionality angular.copy() method?

Latest Posts.

Angularjs Tutorials
AngularJS: A better Option to grow your career

As you may wondering to make your future dependable on AngularJS, here we tell you what an AngularJS...

Angularjs Tutorials
6 AngularJS Frameworks to learn

The AngularJS, one of the most prominent frameworks, has rightly been identified as the leading open...

Angularjs Tutorials
Top 10 key features of Angular 5

Angular JS has been in the industry for quite a few years with micro updates. However, the release o...

Ask a Question