angularjs interview .angularjs interview questions

Download AngularJS Interview .AngularJS Interview Questions

Post on 10-Nov-2018




0 download

Embed Size (px)


  • AngularJS Interview

    Angular JS Angular JS Interview Questions, Best AngularJS Programs and Examples to help you aceyour next Job interview.

    Table of Contents:

    CHAPTER 1: Top 5 Angular JS Interview Questions

    CHAPTER 2: Top 5 Mistakes AngularJS Dev. Makes

    CHAPTER 3: What Is Angular JS

    CHAPTER 4: Advantages Of Angular JS

    CHAPTER 5: Angular JS Interview Questions


  • CHAPTER 6: Angular JS Directive Questions

    CHAPTER 7: Angular JS Security Questions

    CHAPTER 8: Angular JS Testing Interview Questions

    CHAPTER 9: AngularJS VS JQuery

    CHAPTER 10: AngularJS VS ReactJS

    CHAPTER 11: AngularJS Interview Resources

    CHAPTER 12: Summary

    CHAPTER 13: AngularJS Interview Questions PDF

    Importance of AngularJS

    AngularJS is a very popular framework among developers. Small to large companies areusing angularJS. If your going for an interview as a front end developers then get ready toanswer angular JS questions.

    In this guide i have collected and curated the best angularJS interview questions. Gothrough these questions and you will increase your chances of success in interviews.Before we dive deep into this guide. Let's see what are the top 5 questions asked inangularJS interviewsTop 5 AngularJS Interview Questions

    Top 5 Mistakes Angular Js Developers Make2/23

  • These are the top 5 mistakes developers make while developing applications usingAngularJS

    1. Heavy reliance on $scope & not using controller instead2. Overusing $broadcast and $emit3. Overusing $watch4. Failing to Test effectively5. Hacking the DOM

    What is Angular Js

    AngularJS is a structural framework for dynamic web apps. It lets you use HTML asyour template language and lets you extend HTML's syntax to express yourapplication's components clearly.AngularJS's data binding and dependency injection eliminate much of the code youwould otherwise have to write. And it all happens within the browser, making it anideal partner with any server technology.AngularJS provides developers options to write client side application (usingJavaScript) in a clean MVC way.Application written in AngularJS is cross-browser compliant. AngularJS automaticallyhandles JavaScript code suitable for each browser.

    Question: What Are Advantages Of Using AngularJS Framework?

    Some of the key advantages of using AngularJS framework are:

    It provides an excellent experience to the end user.It free's the developers from having to register callbacks manually or write repetitivelow-level DOM manipulation tasks.By separating DOM manipulation from app logic, it makes code modular and easy totest.It supports two-way data binding.

    Question: What Are The Main Features Of AngularJS ?

    Some of the most prominent feature of AngularJS are.

    Data-binding Handles synchronization of data across model, controllers, and view.

    Scope Object representing the model, acts as a glue layer between controller and view.

    Controllers JS functions bound to the scope object.

    Services Substitutable objects that are wired together using dependency injection. e.g.$location service.


  • Filters Formats the value of an expression for displaying to the user. e.g., uppercase,lowercase.

    Directives These are extended HTML attributes start with the ng- prefix. e.g., ng-appdirective used to initialize the angular app.

    Templates HTML code including AngularJS specific elements and attributes.

    Routing Its an approach to switch views.

    MVC pattern A design pattern made up of three parts.

    Model Represents data, could be static data from a JSON file or dynamic data froma database.View Renders data for the user.Controller Gives control over the model and view for collating information to theuser.

    Deep linking Enables the encoding of the application state in the URL and vice versa.Dependency injection A design pattern to let the components injected into each otheras dependencies

    Question: What Is A Digest Cycle in AngularJS?

    During every digest cycle, all new scope model values are compared against the previousvalues. This is called dirty checking. If change is detected, watches set on the new modelare fired and another digest cycle executes. This goes on until all models are stable.

    The digest cycle is triggered automatically but it can be called manually using .$apply().

    Question: What Are Ways Of Communication Between Modules OfApplication, Using AngularJS Functionality?

    The common ways of communication are:

    Using events or servicesBy assigning models on $rootScopeDirectly between controllers using ControllerAs and other forms of inheritanceDirectly between controllers using $parent, $$childHead, $$nextSibling

    Question: How Digest Cycle Can Be Decreased?

    It can be decreased by decreasing the number of watchers. To do this you can:Use web workerWork in batchesCache DOM


  • Remove unnecessary watchersUse one-time Angular binding

    Question: Explain The Steps Involved In Boot Process For AngularJS?

    Whenever a web page loads in the browser, following steps execute in the background.

    First, the HTML file containing the code gets loaded into the browser. After that, theJavaScript file mentioned in the HTML code gets loaded. It then creates a globalobject for angular. Now, the JavaScript which displays the controller functions getsexecuted.In this step, AngularJS browses the complete HTML code to locate the views. If thesame is available, then Angular links it to the corresponding controller function.In this step, AngularJS initiates the execution of required controller functions. Next, itpopulates the views with data from the model identified by the controller. With this thepage is ready.

    Question: Do AngularJS Provide Any Security Features?

    AngularJS provides built-in protection from the following security flaws.

    It prevents cross-site scripting attacks: Cross-site scripting is a technique whereanyone can send a request from client side and can get the confidential informationeasily.It prevents HTML injection attacks.It prevents XSRF protection for server-side communication: Auth token mechanismcan handle it. When the user logins for the first time a user id and password is sent tothe server, and it will, in turn, return an auth token. Now, this token does theauthentication in the future transactions.

    Question: How To Validate Data In AngularJS?

    AngularJS enriches form filling and validation. We can use $dirty and $invalid flags to dothe validations in seamless way. Use novalidate with a form declaration to disable anybrowser specific validation.

    Following can be used to track error.

    $dirty states that value has been changed.$invalid states that value entered is invalid.$error states the exact error.


  • Scopes are controllers specific. If we define nested controllers then child controller willinherit the scope of its parent controller.

    var mainApp = angular.module("mainApp", []);

    mainApp.controller("shapeController", function($scope) {

    $scope.message = "In shape controller";

    $scope.type = "Shape";


    mainApp.controller("circleController", function($scope) {

    $scope.message = "In circle controller";


    Question: What Is Provider?

    provider is used by AngularJS internally to create services, factory etc. during configphase(phase during which AngularJS bootstraps itself).

    Below mention script can be used to create MathService that we've created earlier.Provider is a special factory method with a method get() which is used to return thevalue/service/factory.

    //define a module

    var mainApp = angular.module("mainApp", []);


    //create a service using provider which defines a method square to return square of

    a number.

    mainApp.config(function($provide) {

    $provide.provider('MathService', function() {

    this.$get = function() {

    var factory = {};

    factory.multiply = function(a, b) {

    return a * b;


    return factory;




    Question: What Are Filters? Explain Different Filters Provided ByAngularJS?

    An AngularJS Filter changes or transforms the data before passing it to the view. TheseFilters work in combination with AngularJS expressions or directives. AngularJS uses pipecharacter (|) to add filters to the expressions or directives. For example:


  • {{ bid | currency }}

    The above example is an expr