Angular js Interview question & answer for fresher to experience. - shiva tech

Latest

BANNER 728X90

Saturday 6 February 2016

Angular js Interview question & answer for fresher to experience.

Angular js Interview question & answer for fresher to experience.

What is AngularJS?

AngularJS is structural client side open-source JavaScript Framework developed by Google. AngularJS help us to create single page (one page) application with the help of HTML, CSS, and JavaScript on the client side. As we know that AngularJS follow MVW* pattern and it allow to build well-structured testable & maintainable front end application.

Why We Use Angular Js?

1.     As we know that AngularJS based on MVC pattern help us to organize our web apps or web application properly.

2.     It helps to make responsive & well organized web application that is more expensive & readable.

3.     It follows two way data binding. Two way data binding help us any changes in model will be update view & vice-versa without any manipulation on DOM or events.

4.     AngularJS supports create your own directive that make reusable component to be used according to your requirement. It is also abstract DOM manipulation logic.

5.     It supports services & dependency injection which can easily inject in our controller & provide some utility code as per our requirement.

What Is Angular Js Core Module?

NG is AngularJS core module which is loaded default whenever AngularJS started. NG module provided some essential component for AngularJS app as it is Directive, Services/Factory, Filter & testing components.

How You Describe That Angular Js Different With Other JavaScript Language?

It is well suited for small, large and any sized web app.It directly work on DOM manipulation without any function perform. It supported Pojo (Plane Old Java Script).It have in build form validation. AngularJS is leverages with Dependency Injection.

How you say that Angular Js Dependency in Jquery & how use Jquery with Angular Js?

AngularJS has no dependency on jQuery library. But it can be used with jQuery library. By default AngularJS use jQLite which is the subset of jQuery. Using Jquery Library simply load
the jQuery library before loading the AngularJS.at that it skip jQLite and will started to use jQuery library.

Explain Directives in Angular?

AngularJS directives are a combination of AngularJS template markups (html, css) and also supporting JavaScript code. The JavaScript directive code defines the template data and behaviors of the HTML elements.
Some built-in directives provided by AngularJS like as ng-app, ng-controller, ng-repeat & ng-model.

Explain $scope in Angular?

$Scope is a JavaScript object that refers to the application model. It acts as glue between controller and view. $scope is passed as first argument to controller during its constructor definition.

How you say that root scope related with scope explain it?

If you define nested controllers then child controller will inherit the $scope of its parent controller.
The $rootScope can has one or more child scopes. Each controller has its own $scope so that you create on $scope within controller, these are accessible by the view based on this controller.
More info check my tutorial part4

What is Dependent Module & how it is related with module?
As we know that modules are containers just like namespace in programing language & it divide an angular app into small components which can be integrated with other angular app.All module is dependency with each other.
Note: - every web page (view) can have a single module assigned it via ng-app directive. First Loaded dependent module than loaded core module when angular js start.

Can you define restrict option in directive? & can multiple restrict options possible on a directive?

It specifies how a directive will be invoked in your angular app i.e. as an attribute, class, element or comment.

It has four valid options for restrict:

Attribute(A):- <span my-directive></span>

Class(C) :- <span class="my-directive: expression ;">< /span>

Element(E):- <my-directive></my-directive>

Comment (M) :- <! -- Directive: my-directive expression -->

You can also specify multiple restrict options as: - restrict: 'CA'

What is auto bootstrap process?

When the angular.js script is downloaded to the browser after document.readyState is set to complete. It lookup for ng-app directive (root directive) & load all dependent module which associated with that directive Compile the DOM starting from the ng-app root element. This process is called auto-bootstrapping.

What are Templates in AngularJS?

Templates are the combination of HTML elements, directives, filters, attributes, and expressions. It just pojo that contain elements and attributes.

Describe $watch, $digest and $apply.

$watch: - This function is used to observe changes in a variable on the $scope.it use watch expression, listener & object equality where listener & object equality optional.

$watch (watchExpression, listener, [objectEquality])

$digest: - When $digest () iterates over the watches, it checks if the value of the expression has changed. If the value has changed, AngularJS calls the listener with the new value and the old value.

$digest ()

$apply: - Angular do auto-magically updates only those model changes which are inside AngularJS context. It need to inform Angular of the changes by calling $apply() manually.

$apply ([exp])

Note: - $digest is faster than $apply.

What is Service in AngularJS?

Service is a constructor function which creates the object using new keyword. You can add properties and functions to a service object by using this keyword. Unlike factory, it doesn’t return anything.

What is Factory in AngularJS?

Factory is a simple function which allows you to add some logic before creating the object. It returns the created object.

What is Provider in AngularJS?

A provider is used to create a configurable service object. It returns value by using $get () function, $provide service has a number of methods for registering components with the $injector.

What is $http Service in AngularJS?

It is a core Angular service which allows you to make AJAX requests. It is very much like the $.Ajax () method in jQuery.

$http service supports methods:

 $http.get(), $http.head(), $http.post(), $http.put(), $http.delete(), $http.json(), $http.patch().

What is $q service?

It is a service that helps you to run functions asynchronously, and use their return values when they have done processing.It is used when you need to process a number of asynchronous activities simultaneously.

What is $injector and $inject?

$injector:- it is a service which is used to invoke controller functions, service functions, filter functions, and any other function that might need dependencies as parameters.

$inject: - it is property which is used to inject the dependencies of a function as an array of strings.

What is dependency injection?

Dependency Injection: - Dependency injection (DI) is a design pattern where dependencies are defined in an application as part of the configuration. AngularJS uses dependency injection to load module dependencies when an application first starts. Dependency injection also helps to make an application more testable. That is one of the main advantages of using AngularJS to build JavaScript applications. AngularJS applications are much easier to test than applications written with most JavaScript frameworks.




No comments: