Follow @devglan

angularjs Interview Questions and Answers

Each angularjs Interview Question Sets contains 12 questions.

1)   What is Angular JS?

It is a client side framework (not a library) entirely written in JS. Angular JS is typically used to build single-page-application.

2)   Why we really require Angular JS?

Many JS frameworks compel us to extend from custom Javascript objects and manipulate DOM. Hence, developer requires knowledge of the complete DOM & force complex logic into JS.
Whereas angular auguments HTML to provide native mvc capabilities. Here the developer can encapsulates a portion of the page as one application instead of compelling as entire page to be an angular app. It encourages loose coupling between presentation, data and logic components.

3)   What is the difference between framework and library?

The main difference is the IOC. When you call a method from a library, you are in control of the method. But with a framework, the control os inverted.The framework call you actually.
A library is just a collection of class definitions to increase the code-reuse. But in framework, all the control flow is already there. There is a bunch of white spots that you should fill with your own code.

4)   Give a comparison between jQuery and angular JS.

1. In case of jQuery, first design a page and then make it dynamic. i.e programmatically change the view but in case of angular, start with the architecture & finally design the view.
2. In jQuery the DOM represents the model as selectors are used to find DOM elements and bind event handlers to them but in angular, a separate model layer independent of the view is present.

5)   What is MVC in angular JS?

M stands for Model - Hols the data. It does not know about the view and controller.
V stands for View - Displays stuffs. It only knows about the model.
M stands for Controller - The logic resides in it. It knows about the view and model.

6)   Explain about the directive ng-app in Angular JS?

ng-app attribute is set to an element of DOM. The only components that ere impacted by Angular are the DOM elements that are declared inside the element with ng-app attribute.

7)   What are modules in Angular JS?

Modules are logical entities that an application can be divided into.An app can contain several modules. Each module can contain code for a specific functionality. e.g. angular.module("myApp", []); It accepts two parameters.
1. Name of the module.
2. List of dependencies

8)   What is scope in Angular JS?

The $scope is a plain javascript object. It represents an object that holds the model data to pass the view. It can be treated as a local variable for a controller.

9)   What is $rootScope in Angular JS?

The $rootScope is the eventual parent of all $scope objects. if the controller is nested, the $scope variables will do a lookup in prototypal manner. it is not recommended to attach a lot of logic to this global context.

10)   List the features of controller in Angular JS

1.Controllers are JS functions that are bound to a particular scope.
2.When a new controller is created on a page, Angular provides it a new $scope.
3.This $scope can be used to setup the initial state of the scope of the controller.
4. Angular permits view to call functions on the scope.
5.It allows for the logic of a single view to be contined in a single container.

11)   How do we achieve dependency injection in Angular JS?

myApp.controller("stateController", function($scope, $timeout){
$scope.location.state = "...";
$timeout(function(){
$scope.location.state = "Karnataka";
}, 3000);
});
The built-in $timeout service is injected into the function dynamically.

12)   What is Filter in Angular JS?

Filter provides a mechanism to format the data to be displayed to the user. Filters are invoked in HTML using the | character inside template binding {{}}.
{{location | uppercase}}

Is this page helpful to you? Please give us your feedback below. We would love to hear your thoughts on these articles, it will help us improve further our learning process.