Most Frequently asked AngularJS Interview Questions and Answers for Fresher
1) Describe Angular JS ?
It is a powerful framework of JavaScript. AngularJS is used to design Rich Internet Application. This framework is developed on MVC (Model View Controller) which provide full feature of SPA (Single Page Application) Framework.
2) Give advantages and disadvantages of AngularJS.
Advantages of AngularJS
- User can easily create Single page Application
- Rich and Responsive experienced to user.
- Form Validation is already present.
- It is an open source framework.
- AngularJS is Platform (Browser) Independent.
- It supports Routers and two-way binding.
- A code of AngularJS is Unit testable.
Disadvantages of AngularJS
- Security: It is not secure as build on JavaScript Framework.
- User Dependent: If user disables the JavaScript then AngularJS cannot run.
3) Is jQuery or AngularJS interdependent?
NO, they are not interdependent.
4) Different IDE's that use AngularJS for development?
IDE's are Eclipse, Web Storm, Visual Studio, Text Mate etc.
5) Enlist the Features of AngularJS.
Some AngularJS Features are as Follow:
- MVC
- Validations
- Modules
- Directives
- Templates
- Scope
- Expressions
- Data Binding
- Filters
- Services
- Routing
- Dependency Injection
- Testing
6) Define and Enlist Directives of AngularJS.
AngularJS has DOM element Directives which act as Markers. They attach a specific behaviour to that DOM element and can even transform the DOM element and its children.
Three main core directives are:
7) Define Controller in AngularJS?
In AngularJS to provide data and logic into HTML java script function is used which is known as Controller.
8) Give the use of controller.
- Set up initial state of the $scope object
- Add behaviour to the $scope object.
9) Define Data Binding in AngularJS?
Data binding is used to synchronize the view and model.
10) How are services used in AngularJS?
Services is a function or object that is used in AngularJS. Some of the inbuilt services are $location, $http etc. There are 30 built in services.
11) Define Scope in AngularJS?
Scope is the binding part between view(HTML) and controller(Java Script) through object. It has some properties and method which is available for both view and controller.
12) How to use template in AngularJS?
Template is used to obtain Dynamic view we uses template which consist of HTML+CSS+AngularJS Directives.
13) Write Expression in AngularJS?
It is similar to JavaScript Expression where it consists of literals, operators, and variables.
Eg. {{1+1}} or {{Country+""+State}}.
14) Describe Filter and its use.
Filter is used to transform data it can be embedded in expression or directive.
Eg. Currency, Uppercase, Lower case, Order by.
15) What is “$rootScope†in AngularJS?
$rootScopeData provides a seperation between View and its Model. It is the root directory all other scope is its child scope.
16) What is SPA in AngularJS?
SPA stands for Single Page Application which are web application. It loads a single HTML page and dynamically update that page as the user interacts with the app.
17) What is a Factory method in AngularJS?
Factory method is similar to the services. It is used to create new object and add functions as properties of this object and at the end we return this object.
18) What is REST in AngularJS?
REST stands for Representational State Transfer in AngularJS. It operates over HTTP requests over API. The requested URL identifies the data to be operated on, and the HTTP method identifies the operation that is to be performed.
19) What are the attributes can be used during creation of a new AngularJS Directives?
Following are the list of attributes:
- Restrict: This attribute consists of value "A" (directives to be triggered on the attribute name), "E" (only match element name), “C†(only match class name) and “M†(only match the comment name).
- TemplateUrl: The templateUrl attribute tells the AngularJS HTML compiler to replace custom directive inside a template with HTML content.
- Template: It specify an inline template as a string. Not used if you’re specifying your template as a URL.
- Replace: It has two values true or false. If true, replace the current element. If false or unspecified, append this directive to the current element.
- Transclude: It moves the original children of a directive to a location inside the new template.
- Scope: It create a new scope for this directive rather than inheriting the parent scope.
- Controller: It create a controller which publishes an API for communicating across directives.
- Require: It require that another directive be present for this directive to function correctly.
- Link: It modify resulting DOM element instances, add event listeners, and set up data binding.
- Compile: It modify the DOM template for features across copies of a directive, as when used in other directives.
20) What are the characterstics of Scope?
Data binding is used to synchronize the view and model.
- The $scope is the connection between the HTML and the View.
- $scope provides the execution context for the DOM and the expression
- $scope is modified when the View changes and the View is modified when $the scope changes its value.
- The $rootScope is the parent of all the $scope.
- $scope passes data and behavior to the View.
21) What is AngularJS BootStrap Process?
Bootstrap provide cross platform implementation of UI having consistency among internal tools. It is of two types:
- Automatic Bootstrap
- Manual Bootstrap
22) How would you specify that a scope variable should have one-time binding only?
We can specify the scope by using “::†in front of it. It allows you to check the available variable bindings in AngularJS.
23) Describe angular.copy() method in AngularJS?
angular.copy() method creates a deep copy of the variable. A deep copy of a variable means it doesn’t point to the same memory reference as that variable.
24) What is DDO Directive Definition Object?
DDO is an object used while creating a custome directive.
25) What is an interceptor?
An interceptor is a middleware code where all the $http requests go through. It is registered in $httpProvider. There are 2 types of requests that go through the interceptor, request and response.
27) How to hide HTML element via button click?
It can be done by using directive
ng-hide in conjunction with a controller to hide an HTML element on button click.
28) What is injector?
The injector is a service locator. It is used to retrieve object instances as defined by provider, instantiate types, invoke methods and load modules.
29) Explain what is string interpolation in Angular.js ?
Compiler during the compilation process matches text and attributes using interpolate service to see if they contains embedded expressions.
30) How does the digest phase work?
In digest cycle all scope models are compared against their previous values. If changes are detected, the watches set on that model are fired. Then another digest cycle executes, and so on until all models are stable.