You are on page 1of 5

Angular JS Concept

1. What are the advantages of using Angular.js framework?

Angular.js framework has the following advantages:

Supports two way data-binding


Supports MVC pattern
Support static template and angular template
Can add custom directive
Supports REST full services
Supports form validations
Support both client and server communication
Support dependency injection
Applying Animations
Event Handlers

2. What is Module?

Module is entry point of the project or application .

3. What is scope ?

Scope is an single ton object that can perform data binding through view and model
using controller.

5. Explain data binding in AngularJS. ?

Data-binding in Angular application is the automatic synchronization of data between


the model and view components. When the model changes, the view reflects the
change, and vice versa.

There are two ways of data binding:

i) Data binding in classical template systems


ii) Data binding in angular templates

6. What is directives ?

Directive is a extended HTML attribute that can perform a specific task for the
application.

Example -

<input type=”text” extended=” ”>


.directive(‘extended’,function() {

directive.link = function(scope, elem, attrs, ctrl) {

elem.bind('click',function(){

elem.size = 1000px;

});

});

If click the text box its size increase.

The different types of directives are:


 Element directives
 Attribute directives
 CSS class directives
 Comment directives

7. Tell me some directives in angular.JS?

A) The ng-app directive initializes an Angular JS application.


B) The ng-init directive initializes application data.
C) The ng-model directive binds the value of HTML controls (input, select, text-area)
to application data.

8. Difference between ng-model and ng-bind ?

The ng-model 2 way data binding. Model -------> View & View ----------> Model
The ng-bind onw way data binding. Model -------> View

The ng-model directive binds the value of HTML controls (input, select, text-area).
The ng-bind directive tells Angular JS to replace the content of an HTML element
with the value of a given variable, or expression.
If the value of the given variable, or expression, changes, the content of the specified
HTML element will be changed as well.

9. Difference between ng-if & ng-show/ng-hide ?


A) ng-if will remove elements from DOM. This means that all your handlers or
anything else attached to those elements will be lost.
ng-show/ng-hide does not remove the elements from DOM. It uses CSS styles to
hide/show elements . This way your handlers that were attached to children will not
be lost.

B) ng-if creates a child scope while ng-show/ng-hide does not

9. How to pass vale from one controller to other controller?

1) Root Scope 2) Emit Broadcasting 3) Service

10. What is the difference between link and compile in Angular JS?

Compile function is used for template DOM Manipulation and to collect all the
directives.

Link function is used for registering DOM listeners as well as instance DOM
manipulation and is executed once the template has been cloned.

11. Explain what is injector in Angular JS?

An injector is a service locator, used to retrieve object instance as defined by provider,


instantiate types, invoke methods, and load modules.

12. What is controller ?

13. What is service ?

Services are the singleton constructor 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.Which are instantiated only once in app.

For example $http service is used to make XMLHttpRequests (Ajax calls).

14. What is factory ?

15. Difference between service & factory & Provider?

Service is a constructor object . Service use for single instance. Its return instance of
object
Factory singleton objects.Its use for multiple instance. Its return value. Value may be
object

Provider singleton objects.Its return value of its $get object. Provider is only
configurable service.

http://stackoverflow.com/questions/15666048/angularjs-service-vs-provider-vs-
factory

16. How to implement routing in Angular JS?

It is a five-step process:

Step 1: – Add the “Angular-route.js” file to your view.


Step 2: – Inject “ng-route” functionality while creating Angular app object.
Step 3: – Configure the route provider.
Step 4: – Define hyperlinks.
Step 5: – Define sections where to load the view.

17. How to validate data in Angular JS?

$pre-stined - like vergin, form just loded.


$dirty − states that value has been changed.
$invalid − states that value entered is invalid.
$error − states the exact error.

18. Set Timeout , $timeout concept how we can handle core JavaScript in
angular environment ?

19. Explain $q service how do you implement in your project ?

20. How to use multiple promise ?

Its use $q.all() .Its take array or object

21. Difference between Post link & Pre link ?

Post link DOM manipulated Down to Up


Pre link DOM manipulated Up to Down

22. What is difference between $location.path() and $location.absUrl ?


$location.absUrl() will be 'http://example.com/base/index.html#!/a'(i.e.
$location.absUrl() == 'http://example.com/base/index.html#!/a' is true)
Same with $location.path() will be '/a'
($location.path() == '/a' is true)

You might also like