devquora Devquora is a online network of developers basically a (Developer 2 developer Network) for solving problems day to day common code problems of software developer and programmers. Here anyone can register free any share his/ her programming related problems and questions. On Ddevquora, you can also f 8494 Views

Angular js interview questions

Angular js interview questions

AngularJS interview questions and answers for beginners

Read Angular js interview questions including topic advanced topics like Dependency injection, Two-way binding, Dependency injection, scope in angular js.

Below are the list of top 20 Angularjs interview questions and their answers

  1. Explain, what is AngularJS
  2. Please explain the architecture of AngularJS?
  3. What is the Template in AngularJS?
  4. What is the scope in AngularJS?
  5. What is the controller in AngularJS?
  6. Explain Directives in AngularJs?
  7. List some tools for testing AngularJS applications?
  8. How do you share data between controllers in AngularJs?
  9. Explain AngularJS digest cycle?
  10. What is internationalization in AngularJS?
  11. Difference between AngularJS and JavaScript Expressions
  12. Explain basic steps to set up an Angular app?
  13. What are Angular Modules?
  14. Explain Directive scopes?
  15. How to isolate a directive's Scope in Angular?
  16. What is the difference between one-way binding and two-way binding?
  17. How would you make an Angular service return a promise? Write a code snippet as an example.
  18. Explain the role of $routeProvider in AngularJS?
  19. Explain how does Angular implement two-way binding?
  20. What is dependency injection and how does it work?

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 are changes 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 placed 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 AngularJS.

  • 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 the 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


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

Read 80+ AngularJS Interview Questions

  • 0
  • 0
  • 0
Angular2 interview questions

Angular2 interview questions..

Dear friends, below are the list of Angular2 interview questions that have been designed..

devquora devquora
Angular 4 interview questions

Angular 4 interview questions..

Below are the list of top 20 Angular 4 interview questions with their answers. here you can field mo

devquora devquora
IONIC framework interview questions and answers

IONIC framework interview ques..

Set of top Ionic Framework interview questions and answers. Below are list of Latest Ionic framework

devquora devquora