Angular JS Interview Questions



1. What is AngularJS?  

AngularJS is a framework to build large scale and high performance web application while keeping them as easy-to-maintain. Following are the features of AngularJS framework.
  • AngularJS is a powerful JavaScript based development framework to create RICH Internet Application (RIA).
  • AngularJS provides developers options to write client side application (using JavaScript) in a clean MVC (Model View Controller) way.
  • Application written in AngularJS is cross-browser compliant. AngularJS automatically handles JavaScript code suitable for each browser.
  • AngularJS 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. Why to use AngularJS?  

There are following reasons to choose AngularJS as a web development framework:
  • It is based on MVC pattern which helps you to organize your web apps or web application properly.
  • It extends HTML by attaching directives to your HTML markup with new attributes or tags and expressions in order to define very powerful templates.
  • It also allows you to create your own directives, making reusable components that fill your needs and abstract your DOM manipulation logic.
  • It supports two-way data binding i.e. connects your HTML (views) to your JavaScript objects (models) seamlessly. In this way any change in model will update the view and vice versa without any DOM manipulation or event handling.
  • It encapsulates the behaviour of your application in controllers which are instantiated with the help of dependency injection.
  • It supports services that can be injected into your controllers to use some utility code to fulfil your need. For example, it provides $http service to communicate with REST service.
  • It supports dependency injection which helps you to test your angular app code very easily.
  • Also, AngularJS is mature community to help you. It has widely support over the internet.


3. Why this project is called "AngularJS"?  

Html has angle brackets i.e. <,> and ng sound like Angular. That’s why it is called AngularJS.


4. What are the advantages of AngularJS?  

There are following advantages of AngularJS:
  • Data Binding - AngularJS provides a powerful data binding mechanism to bind data to HTML elements by using scope.
  • Customize & Extensible - AngularJS is customized and extensible as per you requirement. You can create your own custom components like directives, services etc.
  • Code Reusability - AngularJS allows you to write code which can be reused. For example custom directive which you can reuse.
  • Support – AngularJS is mature community to help you. It has widely support over the internet. Also, AngularJS is supported by Google which gives it an advantage.
  • Compatibility - AngularJS is based on JavaScript which makes it easier to integrate with any other JavaScript library and runnable on browsers like IE, Opera, FF, Safari, Chrome etc.
  • Testing - AngularJS is designed to be testable so that you can test your AngularJS app components as easy as possible. It has dependency injection at its core, which makes it easy to test.



5. How AngularJS is different from other JavaScript Framework?  

Today, AngularJS is the most popular and dominant JavaScript framework for professional web development. It is well suited for small, large and any sized web app and web application.


AngularJS is different from other JavaScript framework in following ways:
  • AngularJS mark-up lives in the DOM.
  • AngularJS uses plain old JavaScript objects (POJO).
  • AngularJS is leverages with Dependency Injection.


6. What IDEs you can use for AngularJS development?  

AngularJS development can be done with the help of following IDEs:
  • Visual Studio 2012, 2013, 2015 or higher
  • Eclipse
  • WebStorm
  • Sublime Text
  • TextMate


7. Does AngularJS has dependency on jQuery?  

AngularJS has no dependency on jQuery library. But it can be used with jQuery library.


8. How to use jQuery with AngularJS?  

By default AngularJS use jQLite which is the subset of jQuery. If you want to use jQuery then simply load the jQuery library before loading the AngularJS. By doing so, Angular will skip jQLite and will started to use jQuery library.


9. Is AngularJS a library, framework, plugin or a browser extension?  

AngularJS is a first class JavaScript framework which allows you to build well structured, easily testable, and maintainable front-end applications. It is not a library since library provides you limited functionality or has dependencies to other libraries.It is not a plugin or browser extension since it is based on JavaScript and compatible with both desktop and mobile browsers.



10. What browsers AngularJS support?  

The latest version of AngularJS 1.3 support Safari, Chrome, Firefox, Opera 15+, IE9+ and mobile browsers (Android, Chrome Mobile, iOS Safari, Opera Mobile). AngularJS 1.3 has dropped support for IE8 but AngularJS 1.2 will continue to support IE8.



11. What is the size of angular.js file?  

The size of the compressed and minified file is < 36KB.


12. What are AngularJS features?  

  • Modules
  • Directives
  • Templates
  • Scope
  • Expressions
  • Data Binding
  • MVC (Model, View & Controller)
  • Validations
  • Filters
  • Services
  • Routing
  • Dependency Injection
  • Testing


13. How AngularJS handle the security?  

AngularJS provide following built-in protection from basic security holes:
  • Prevent HTML injection attacks
  • Prevent Cross-Site-Scripting (CSS) attacks
  • Prevent XSRF protection for server side communication

Also, AngularJS is designed to be compatible with other security measures like Content Security Policy (CSP), HTTPS (SSL/TLS) and server-side authentication and authorization that greatly reduce the possible attacks.



14. What are Modules in AngularJS?  

AngularJS modules are containers just like namespace in C#. They divide an angular app into small, reusable and functional components which can be integrated with other angular app. Each module is identified by a unique name and can be dependent on other modules. In AngularJS, every web page (view) can have a single module assigned to it via ng-app directive.




15. What components can be defined within AngularJS modules?  

  • Directive
  • Filter
  • Controller
  • Factory
  • Service
  • Provider
  • Value
  • Config settings and Routes


16. What is core module in AngularJS?  

ng is the core module in angular. This module is loaded by default when an angular app is started. This module provides the essential components for your angular app like directives, services/factories, filters, global APIs and testing components.



17. How angular modules load the dependencies?  

An angular module use configuration and run blocks to inject dependencies (like providers, services and constants) which get applied to the angular app during the bootstrap process.



18. What is difference between config() and run() method in AngularJS?  

Configuration block

This block is executed during the provider registration and configuration phase. Only providers and constants can be injected into configuration blocks. This block is used to inject module wise configuration settings to prevent accidental instantiation of services before they have been fully configured. This block is created using config() method.

Run block

This block is executed after the configuration block. It is used to inject instances and constants. This block is created using run() method. This method is like as main method in C or C++. The run block is a great place to put event handlers that need to be executed at the root level for the application. For example, authentication handlers.



19. When dependent modules of a module are loaded?  

A module might have dependencies on other modules. The dependent modules are loaded by angular before the requiring module is loaded.

In other words the configuration blocks of the dependent modules execute before the configuration blocks of the requiring module. The same is true for the run blocks. Each module can only be loaded once, even if multiple other modules require it.



20. What is Angular Prefixes $ and $$?  

To prevent accidental name collisions with your code, Angular prefixes names of public objects with $ and names of private objects with $$. So, do not use the $ or $$ prefix in your code.



Java Interview Question

.Net Interview Question

PHP Interview Question

AngularJS Interview Questions