Angular JS Interview Questions & Answers

5 avg. rating (100% score) - 1 votes

Angular JS Interview Questions & Answers

Planning for a career opportunity in Angular JS or thinking to further excel as an expert, what ever is your preparation for, get on to wisdomjobs and improve your knowledge base to get hired for any kind of Angular JS jobs. Look for any Angular JS job interview questions and answers page, one like ours to get a winning position in companies. Get into this dominating and fast growing JavaScript framework career path easily running against competition by going through the pile of useful information on our site. If you’re an employer finding for Angular JS Q&A’s to hone in a right candidate both freshers as well an experienced that best fit your needs then you’re at the right place. Explore our site for more details.

Angular JS Interview Questions

Angular JS Interview Questions
    1. Question 1. What Is Angular Js?

      Answer :

      Angular JS is a framework to build large scale and high performance web application while keeping them as easy-to-maintain. 
      Following are the features of Angular JS framework.
      1.Angular JS is a powerful JavaScript based development framework to create RICH Internet Application (RIA).
      2.Angular JS provides developers options to write client side application (using JavaScript) in a clean MVC (Model View Controller) way.
      3.Application written in Angular JS is cross-browser compliant. Angular JS automatically handles JavaScript code suitable for each browser.
      4.Angular JS is open source, completely free, and used by thousands of developers around the world. It is licensed under the Apache License version 2.0.

    2. Question 2. What Is Data Binding In Angular Js?

      Answer :

      Data binding is the automatic synchronization of data between model and view components. ng-model directive is used in data binding.

    3. Question 3. What Is Scope In Angular Js?

      Answer :

      Scopes are objects that refer to the model. They act as glue between controller and view.

    4. Question 4. What Are The Controllers In Angular Js?

      Answer :

      Controllers are JavaScript functions that are bound to a particular scope. They are the prime actors in Angular JS framework and carry functions to operate on data and decide which view is to be updated to show the updated model based data.

    5. Question 5. What Are The Services In Angular Js?

      Answer :

      Angular JS come with several built-in services. For example $http service is used to make XMLHttpRequests (Ajax calls). Services are singleton objects which are instantiated only once in app.

    6. Question 6. What Are The Filters In Angular Js?

      Answer :

      Filters select a subset of items from an array and return a new array. Filters are used to show filtered items from a list of items based on defined criteria.

    7. Question 7. Explain Directives In Angular Js.

      Answer :

      Directives are markers on DOM elements (such as elements, attributes, css, and more). These can be used to create custom HTML tags that serve as new, custom widgets. Angular JS has built-in directives (ng-bind, ng-model, etc) to perform most of the task that developers have to do.

    8. Question 8. Explain Templates In Angular Js.

      Answer :

      Templates are the rendered view with information from the controller and model. These can be a single file (like index.html) or multiple views in one page using “partials”.

    9. Question 9. What Is Routing In Angular Js?

      Answer :

      It is concept of switching views. Angular JS based controller decides which view to render based on the business logic.

    10. Question 10. What Is Deep Linking In Angular Js?

      Answer :

      Deep linking allows you to encode the state of application in the URL so that it can be bookmarked. The application can then be restored from the URL to the same state.

    11. Question 11. What Are The Advantages Of Angular Js?

      Answer :

      Advantages of Angular JS:
      1.Angular JS provides capability to create Single Page Application in a very clean and maintainable way.
      2.Angular JS provides data binding capability to HTML thus giving user a rich and responsive experience.
      3.Angular JS code is unit testable.
      4.Angular JS uses dependency injection and make use of separation of concerns.
      5.Angular JS provides reusable components.
      6.With Angular JS, developer writes less code and gets more functionality.
      7.In Angular JS, views are pure html pages, and controllers written in JavaScript do the business processing.
      8.Angular JS applications can run on all major browsers and smart phones including Android and iOS based phones/tablets.

    12. Question 12. How To Implement Internationalization In Angular Js?

      Answer :

      Angular JS supports inbuilt internationalization for three types of filters currency, date and numbers. We only need to incorporate corresponding js according to locale of the country. By default it handles the locale of the browser. For example, to use Danish locale, use following script

    13. Question 13. What Is Internationalization?

      Answer :

      Internationalization is a way to show locale specific information on a website. For example, display content of a website in English language in United States and in Danish in France.

    14. Question 14. On Which Types Of Component Can We Create A Custom Directive?

      Answer :

      Angular JS provides support to create custom directives for following type of elements.
      Element directives − Directive activates when a matching element is encountered.
      Attribute − Directive activates when a matching attribute is encountered.
      CSS − Directive activates when a matching css style is encountered.
      Comment − Directive activates when a matching comment is encountered.

    15. Question 15. Which Components Can Be Injected As A Dependency In Angular Js?

      Answer :

      Angular JS provides a supreme Dependency Injection mechanism. It provides following core components which can be injected into each other as dependencies.
      1.value
      2.factory
      3.service
      4.provider
      5.constant

    16. Question 16. Is Angular Js Extensible?

      Answer :

      Yes! In AngularJS we can create custom directive to extend AngularJS existing functionalities.
      Custom directives are used in AngularJS to extend the functionality of HTML. Custom directives are defined using “directive” function. A custom directive simply replaces the element for which it is activated.
      AngularJS application during bootstrap finds the matching elements and do one time activity using its compile() method of the custom directive then process the element using link() method of the custom directive based on the scope of the directive.

    17. Question 17. What Is Constant?

      Answer :

      constants are used to pass values at config phase considering the fact that value cannot be used to be passed during config phase.
      mainApp.constant(“configParam”, “constant value”);

    18. Question 18. What Are The Differences Between Service And Factory Methods?

      Answer :

      factory method is used to define a factory which can later be used to create services as and when required whereas service method is used to create a service whose purpose is to do some defined task.

    19. Question 19. What Is Factory Method?

      Answer :

      Using factory method, we first define a factory and then assign method to it.
      var mainApp = angular.module(“mainApp”, []);
      mainApp.factory(‘MathService’, function() { 
          var factory = {}; 
          factory.multiply = function(a, b) {
              return a * b 
          }
          return factory;
      });

    20. Question 20. What Is Service Method?

      Answer :

      Using service method, we define a service and then assign method to it. We’ve also injected an already available service to it.

      mainApp.service(‘CalcService’, function(MathService)
      {
          this.square = function(a) { 
              return MathService.multiply(a,a); 
          }
      });

    21. Question 21. What Is A Service?

      Answer :

      Services are JavaScript functions and are responsible to do specific tasks only. Each service is responsible for a specific task for example, $http is used to make ajax call to get the server data. $route is used to define the routing information and so on. Inbuilt services are always prefixed with $ symbol.

    22. Question 22. What Is Use Of $routeprovider In Angular Js?

      Answer :

      $routeProvider is the key service which set the configuration of urls, maps them with the corresponding html page or ng-template, and attaches a controller with the same.

    23. Question 23. What Is $rootscope?

      Answer :

      Scope is a special JavaScript object which plays the role of joining controller with the views. Scope contains the model data. In controllers, model data is accessed via $scope object. $rootScope is the parent of all of the scope variables.

    24. Question 24. How To Make An Ajax Call Using Angular Js?

      Answer :

      AngularJS provides $http control which works as a service to make ajax call to read data from the server. The server makes a database call to get the desired records. AngularJS needs data in JSON format. Once the data is ready, $http can be used to get the data from server in the following manner:
      function studentController($scope, $http) {
          var url = “data.txt”;
          $http.get(url).success( function(response) {
              $scope.students = response; 
          });
      }

    25. Question 25. How To Validate Data In Angular Js?

      Answer :

      AngularJS enriches form filling and validation. We can use $dirty and $invalid flags to do the validations in seamless way. Use novalidate with a form declaration to disable any browser 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.

    26. Question 26. How Angular.module Works?

      Answer :

      angular.module is used to create AngularJS modules along with its dependent modules.
      Consider the following example:
      var mainApp = angular.module(“mainApp”, []);
      Here we’ve declared an application mainApp module using angular.module function. We’ve passed an empty array to it. This array generally contains dependent modules declared earlier.

    27. Question 27. Explain Ng-click Directive?

      Answer :

      ng-click directive represents a AngularJS click event.
      In below example, we’ve added ng-click attribute to a HTML button and added an expression to updated a model. Then we can see the variation.

      <p>Total click: {{ clickCounter }}</p></td>
      <button ng-click = “clickCounter = clickCounter + 1”>Click Me!</button>

    28. Question 28. Explain Ng-hide Directive?

      Answer :

      ng-hide directive hides a given control.
      In below example, we’ve added ng-hide attribute to a HTML button and pass it a model. Then we’ve attached the model to a checkbox and can see the variation.

      <input type = “checkbox” ng-model = “showHide2”>Hide Button
      <button ng-hide = “showHide2”>Click Me!</button>

    29. Question 29. Explain Order By Filter?

      Answer :

      orderby filter orders the array based on provided criteria.
      In below example, to order subjects by marks, we’ve used orderBy marks.
      Subject:

      <ul>
      <li ng-repeat = “subject in student.subjects | orderBy:’marks'”>
      {{ subject.name + ‘, marks:’ + subject.marks }}
      </li>
      </ul>

    30. Question 30. Explain Ng-disabled Directive?

      Answer :

      ng-disabled directive disables a given control.
      In below example, we’ve added ng-disabled attribute to a HTML button and pass it a model. Then we’ve attached the model to an checkbox and can see the variation.
      <input type = “checkbox” ng-model = “enableDisableButton”>Disable Button
      <button ng-disabled = “enableDisableButton”>Click Me!</button>

    31. Question 31. Explain Ng-show Directive?

      Answer :

      ng-show directive shows a given control.
      In below example, we’ve added ng-show attribute to a HTML button and pass it a model. Then we’ve attached the model to a checkbox and can see the variation.

      <input type = “checkbox” ng-model = “showHide1”>Show Button
      <button ng-show = “showHide1”>Click Me!</button>

    32. Question 32. Explain Currency Filter?

      Answer :

      Currency filter formats text in a currency format.
      In below example, we’ve added currency filter to an expression returning number using pipe character. Here we’ve added currency filter to print fees using currency format.

      Enter fees: <input type = “text” ng-model = “student.fees”>
      fees: {{student.fees | currency}}

    33. Question 33. Explain Filter Filter?

      Answer :

      filter filter is used to filter the array to a subset of it based on provided criteria.
      In below example, to display only required subjects, we’ve used subjectName as filter.

      Enter subject: <input type = “text” ng-model = “subjectName”>
      Subject:
      <ul>
      <li ng-repeat = “subject in student.subjects | filter: subjectName”>
      {{ subject.name + ‘, marks:’ + subject.marks }}
      </li>
      </ul>

    34. Question 34. Explain Uppercase Filter?

      Answer :

      Uppercase filter converts a text to upper case text.
      In below example, we’ve added uppercase filter to an expression using pipe character. Here we’ve added uppercase filter to print student name in all capital letters.

       Enter first name:<input type = “text” ng–model = “student.firstName”>                        
                   Enter last name: <input type = “text” ng–model = “student.lastName”>                    
                   Name in Upper Case: {{student.fullName() | uppercase}}

    35. Question 35. Explain Ng-repeat Directive ?

      Answer :

      ng-repeat directive repeats html elements for each item in a collection.

    36. Question 36. What Are Angular Js Expressions?

      Answer :

      Expressions are used to bind application data to html. Expressions are written inside double braces like {{ expression}}. Expressions behave in same way as ng-bind directives. AngularJS application expressions are pure JavaScript expressions and outputs the data where they are used.

    37. Question 37. Explain Ng-init Directive ?

      Answer :

      ng-init directive initializes an AngularJS Application data. It is used to put values to the variables to be used in the application.

    38. Question 38. Explain Ng-controller Directive ?

      Answer :

      Ng-controller directive tells AngularJS what controller to use with this view. AngularJS application mainly relies on controllers to control the flow of data in the application. A controller is a JavaScript object containing attributes/properties and functions. Each controller accepts $scope as a parameter which refers to the application/module that controller is to control.

    39. Question 39. How Angular Js Integrates With Html?

      Answer :

      AngularJS being a pure javaScript based library integrates easily with HTML.
      Step 1 − Include angularjs javascript libray in the html page
      <head> src = “http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js&#8221;> </head>
      Step 2 − Point to AngularJS app
      Next we tell what part of the HTML contains the AngularJS app. This done by adding the ng-app attribute to the root HTML element of the AngularJS app. You can either add it to html element or body element as shown below:
      <body ng-app = “myapp”> </body>

    40. Question 40. Explain Ng-app Directive?

      Answer :

      ng-app directive defines and links an AngularJS application to HTML. It also indicate the start of the application.

    41. Question 41. Explain Ng-model Directive?

      Answer :

      ng-model directive binds the values of AngularJS application data to HTML input controls. It creates a model variable which can be used with the html page and within the container control( for example, div) having ng-app directive.

    42. Question 42. Explain Ng-bind Directive ?

      Answer :

      ng-bind directive binds the AngularJS Application data to HTML tags. ng-bind updates the model created by ng-model directive to be displayed in the html tag whenever user input something in the control or updates the html control’s data when model data is updated by controller.

    43. Question 43. Explain Angular Js Boot Process.

      Answer :

      When the page is loaded in the browser, following things happen:
      · HTML document is loaded into the browser, and evaluated by the browser. Angular JS JavaScript file is loaded; the angular global object is created. Next, JavaScript which registers controller functions is executed.
      · Next Angular JS scans through the HTML to look for Angular JS apps and views. Once view is located, it connects that view to the corresponding controller function.
      · Next, Angular JS executes the controller functions. It then renders the views with data from the model populated by the controller. The page gets ready.

    44. Question 44. Which Are The Core Directives Of Angular Js?

      Answer :

      Following are the three core directives of AngularJS.
      ng-app − This directive defines and links an AngularJS application to HTML.
      ng-model − This directive binds the values of AngularJS application data to HTML input controls.
      ng-bind − This directive binds the AngularJS Application data to HTML tags.


Face Book Twitter Google Plus Instagram Youtube Linkedin Myspace Pinterest Soundcloud Wikipedia

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Javascript Advanced Tutorial