AngularJS Interview Questions

 Q #1) What do you understand by AngularJS?

Answer: AngularJS is a JavaScript framework that is used for making rich and extensible web applications.

It runs on plain JavaScript and HTML, hence 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 .know more at Angular JS online training

Q #2) Define the features of AngularJS.

Answer: The features include:

  • The Template (View)
  • The Scope (Model)
  • The Controller (Controller)
  • Services
  • Filters
  • Directives

Q #3) Define Data Binding.

Answer: Data binding is an automatic attunement of data between the view and model components.

Q #4) Distinguish between AngularJS and JavaScript expressions.

Answer: There are several differences between AngularJS and JavaScript expressions:

  • We can write AngularJS expressions in HTML, but we cannot write JavaScript expressions in HTML.
  • We cannot use conditional iterations, loops, and exceptions in AngularJS, but we can use all of these conditional properties in JavaScript expressions.
  • Filters are supported in AngularJS whereas filters are not supported in JavaScript.

Q #5) Write all the steps to configure an Angular App(ng-app).

Answer: To set up an Angular App we must follow certain steps as mentioned below:

  • angular.module will be created at first.
  • A controller will be assigned to the module.
  • The module will be linked with the HTML template(i.e. UI or View) with an angular app(ng-app).
  • The HTML template will be linked with the controller(i.e JS) with an ng-controller directive.

Q #6) What are the Angular Modules?

Answer: The angular modules collectively define an angular application where we can write the angular code. Modules contain the different parts of an angular application. A module is created by angular.module function in angular.

Q #7) What are the directive scopes in AngularJS?

Answer: Three directive scopes are available in AngularJS.

They are:

  • Parent scope: Whatever change you make in your directive that comes from the parent scope, will also reflect in the parent scope, and it is also a default scope.
  • Child scope: It is a nested scope that inherits a property from the parent scope. Also, if any properties and function on the scope are not connected with the parent scope directive, then a new child scope directive is created.
  • Isolated scope: It is reusable and is used when we build a self-contained directive. It is only used for private and internal use which means that it does not contain any properties of the parent scope. know more at Angular js training

Q #8) How can we share the data between controllers in AngularJS?

Answer: First, we have to create a service. Service is used to share the data between controllers in AngularJS in a very lucid, easy and fastest way. We use events, $parent, next sibling, and controller by using a $rootScope.

Q #9) What is the digest cycle in AngularJs?

Answer: It is a part of the process of data binding in AngularJS. It compares the old and new versions of the scope model value in each digest cycle.

The digest cycle is triggered automatically. We can also enhance the usability by using $apply () if we want to trigger the digest cycle manually.

Q #10) Explain the differences between one-way binding and two-way binding.

Answer: One-way binding is used to bind the data from the model to view without updating the HTML template or view automatically.

Thus, in order to update the HTML template, we need to write a custom code that will update the view every time whenever a data is binded from model to view.

Whereas, two-way binding is used to bind the data from the model to view and vice versa(i.e view to model) by automatically updating the HTML template without writing any custom code.

Q #11) Difference between sessionStorage, cookies, and localStorage.

Answer: The differences are as follows:

  • SessionStorage – The data is stored for a particular session. The data will be lost whenever the browser tab will be closed or after some particular session. The maximum size stored can be up to 5MB.
  • LocalStorage – The data is stored with no expiration date. The data can only be cleared by JavaScript or by clearing the browser cache. The storage limit is maximum than the sessionStorage and cookie.
  • Cookies – It stores the data that has to be sent back to the server with some requests. The cookie’s expiration varies on the type and duration set from either the server-side or client-side. The maximum size stored can be less than 4KB.

Q #12) What is the role of $routeProvider in AngularJS?

Answer: It is the $routeProvider that helps in navigating between different pages/links without separately loading the page/link whenever a user clicks on a link.

ngRoute config() method is used to configure the routeProvider.

Q #13) What is the difference between $scope and scope?

Answer: In AngularJS, $scope is used to achieve dependency injection and scope is used for linking between View (i.e HTML) and Controller (i.e JS).

Q #14) How are AngularJS prefixes $ and $$ used?

Answer: $$ variable in AngularJS is used as a private variable, as it is used to prevent accidental code collision with the user code.

Whereas, $ prefix can be used to denote angular core functionalities (like a variable, parameter, property or method).

Q #15) Where can we implement the DOM manipulation in AngularJS?

Answer: Manipulation of DOM is in directives and apart from this it should not exist in the controller’s services or anywhere else.

Q #16) How can we show that a scope variable should have one-time binding only?

Answer: To show one-time binding we have to use “::” in front of the scope.

Q #17) What is SPA (Single Page Application) in AngularJS?

Answer: It is a web application that loads a single HTML page and dynamically updates the page as the user connects with the app.

By using AJAX and HTML a fluid and responsive web app can be created by SPA without invariant page reloads. Through this, we can make responsive UI with no page flicker. know more at Angular js online training from India

Q #18) How many types of data bindings are there in AngularJS?

Answer: AngularJS supports both one way and two-way binding.

In one way binding if we change the data model, then there will be no dynamic change that you will see in view but in two way binding, there will be a dynamic change whenever a change will be made in the data model.

Data bindings in AngularJS

Q #19) What are the binding directives in AngularJs?

Answer: The binding directives include:

  • ng-bind
  • ng-bind-html
  • ng-bind-template
  • ng-non-bindable
  • ng-model

Q #20) Explain ng-bind and ng-bind-html directives.

Answer:

ng-bind: It is a directive that replaces the content of the HTML element with the value of the assigned variable or expression.

The content of the HTML element will change by changing the value of the variable or expression.

It is like ({{expression}}) and the syntax for this is, know more at Angular js online course

Q #21) Explain ng-bind-template and ng-non-bindable.

Answer:

ng-bind-template: It replaces the text content of the element by interpolation of the template. It can contain multiple double curly markups.

Comments

Popular posts from this blog

What is Tableau?

SharePoint Interview Questions

Testing Interview Questions