AngularJS Interview Questions


Q#1. What is AngularJS?

Ans. Angular is an open-source front-end web framework. It is one of the most popular JavaScript frameworks that is mainly maintained by Google. It provides a platform for easy development of web-based applications and empowers the front end developers in curating cross-platform applications. It integrates powerful features like declarative templates, an end to end tooling, dependency injection and various other best practices that smoothens the development path.


Q#2. Explain what is scope in AngularJS ?

Ans. Scope refers to the application model, it acts like glue between application controller and the view. Scopes are arranged in hierarchical structure and impersonate the DOM ( Document Object Model) structure of the application. It can watch expressions and propagate events.


Q#3. What are the controllers in AngularJS?

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


Q#4. Explain what is services in AngularJS ?

Ans. In AngularJS services are the singleton objects or functions that are used for carrying out specific tasks. It holds some business logic and these function can be called as controllers, directive, filters and so on.


Q#5. What is Angular mainly used for?

Ans. Angular is typically used for the development of SPA which stands for Single Page Applications. Angular provides a set of ready-to-use modules that simplify the development of single page applications. Not only this, with features like built-in data streaming, type safety, and a modular CLI, Angular is regarded as a full-fledged web framework.


Q#6. What are the filters in AngularJS?

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


Q#7. Explain what are directives ? Mention some of the most commonly used directives in AngularJS application ?

Ans. A directive is something that introduces new syntax, they are like markers on DOM element which attaches a special behavior to it. In any AngularJS application, directives are the most important components. Some of the commonly used directives are ng-model, ng-App, ng-bind, ng-repeat , ng-show etc.


Q#8. What are templates in Angular?

Ans. Templates in Angular are written with HTML that contains Angular-specific elements and attributes. These templates are combined with information coming from the model and controller which are further rendered to provide the dynamic view to the user.


Q#9. Explain what Angular JS routes does ?

Ans. Angular js routes enable you to create different URLs for different content in your application. Different URLs for different content enables user to bookmark URLs to specific content. Each such bookmarkable URL in AngularJS is called a route A value in Angular JS is a simple object. It can be a number, string or JavaScript object. Values are typically used as configuration injected into factories, services or controllers. A value should be belong to an AngularJS module. Injecting a value into an AngularJS controller function is done by adding a parameter with the same name as the value


Q#10. In Angular what is string interpolation?

Ans. String interpolation in Angular is a special syntax that uses template expressions within double curly {{ }} braces for displaying the component data. It is also known as moustache syntax. The JavaScript expressions are included within the curly braces to be executed by Angular and the relative output is then embedded into the HTML code. These expressions are usually updated and registered like watches, as a part of the digest cycle.