AngularJS Interview Questions and Answers

What is AngularJS?

AngularJS is open source, JavaScript based framework which simplify the creation of single page web application.
Initially AngularJS was developed by MiskoHevery and Adam Abrons, and now it is built and maintained by Google. 
 

Why to use AngularJS?

1.    Easy to maintain , open source and cross browser compatible 
2.    Based on MVC (Model View Control) pattern
3.    Supports REST full services
4.    Supports two way data binding
5.    Supports form validations
6.    supports animation and Event Handling
7.    Extensible and testable
8.    Support dependency injection

Do I need jQuery for Angular?

No, Angular has its own subset of jQuery calledjQLite.
If jQuery present in the application then Angular use it. If jQuery is not located in the application script path, Angular usedjQLite.

Explain major components of AngularJS?

There are following major components of AngularJS
Module: It work as containers for components. Whereas an AngularJS application can have multiple modules.

Config: The config block represent module wise configuration settings for AngularJS application, whichapplied before application runs. 

Routes: Routes define a way between view loading and controller whereas multiple view can available on single page AngularJS application.

Views: The view is UI DOM on user browserafter rendering ofAngularJS Htmlpage.

Scope: It works between the view and controller within an AngularJS application and synchronize them.

Controller: The controller is acts as bridge between services and views, and responsible for defining methods and properties that the view can bind toand interact. 

Directive: directive extend behaviour of Html elementand allow to create custom,reusable elements that encapsulate behaviour. 

Service: Services provide functionality to an AngularJS application and extend controllers and make them more globally accessible.
 

What are Modules in AngularJS?

AngularJS modules work ascontainers. They logically divide an angular app into small, reusable and functional components. Each module is identified by a unique name and can be dependent on other modules. 
In AngularJS, ng is the core module and loaded by default when an angular app is started.

What are directives in AngularJS?

Directives are the AngularJS elements in Html tag that extend behaviour of Html element. All AngularJS directives start with the word "ng".
There are many built-in directives in AngularJS such as "ng-app", "ng-model", "ng-controller", "ng-repeat" etc.

What are the different types of directive in AngularJS?

In Angular, types of directives depending on their implementation on HTML tag.
So there are four types of directives-
Element directives
Attribute directives
CSS class directives
Comment directives

What is controller in AngularJS?

Controller is acting between the view and the services, whereas it is responsible for consuming data from services, processing data for display in the view, and transmitting data back to services for logic processing.
It should be lightweight and isolated from views.

What is data binding in AngularJS?

Data binding is the finest feature of theAngularJS, It is the automatic synchronization of the data between the model and view components. Whereas the view is a projection of the modelthat change withmodel changes, and vice versa.
There are two ways of data binding:
One way data binding (used in classical template)
Two way data binding (used in AngularJS template)

What are services in AngularJS?

AngularJS Services are the singleton functions or objects and used forprovide some functionality to the application. Services are prefixed with $ symbol and available globally to the entire application.

Ex.$http service is used forserver-side communication, $resource serviceused for support RESTful web services

What is scope in AngularJS?

Scope is a JavaScript object which synchronize controller with the views.
An AngularJS application has single $rootscope.The root scope has one or more child$scope objects associated with it whereas child scope inherits properties from its parent scope.

What is templateand view in AngularJS?

HTML element that contains Angular-specific attributes and directives called template in AngularJS.Whereas a view is the HTML after template has been through the AngularJS compilation process

Explain what are AngularJS routes does?

AngularJS routes enable you to create different URLs for different content in your application page without reloading the entire application. Different URLs for different content enables user to bookmark URLs to specific content. In AngularJS each such bookmarkable URL is called a route.

What are expressions in AngularJS?

Expressions are the code snippets that resolves to a value and used tobind application data to html. AngularJS expressions are placed inside {{expression}}.

What is the difference between AngularJS expressions and JavaScript expressions?

The main difference between the JavaScript expressions and Angular expressions are: 

•    TheJavaScript expressions are evaluated against the global window object, whereas in Angular the expressions are evaluatedagainst a scope object.

•    In JavaScript, undefined properties produces ReferenceError or TypeError, while In Angular expression evaluation is forgiving to undefined and null.

•    AngularJS expression doesn’t support loop, condition and exception, while java script do.

•    In AngularJS, filters can be used with expression to format data before displaying it but in JavaScript we can’t.

What is the use of filter in AngularJS?

A filter is used to format the value of expression to display the formatted output. AngularJS enables us to write our own filter.
It can be used in an expression with pipe character.
Examples
Name in lower Case: {{student.fullName() | lowercase}}

Latest Updates

General Knowledge of India

Which of the following dance forms was introduced by the great Vaishnava saint and reformer Mahapurusha Sankaradeva ?

Which of the following is the only classical dance of india having links with Muslim culture and represents a unique synthesis of Hindu and Muslim genius in art ?

Time and Distance

Starting from the same point at the same time, Ruhan and Yuvan had to reach the same destination. While Ruhan drove at 45 km/hr, Yuvan was slower by 5 km/hr. If Yuvan arrived at the destination an hour after Ruhan did, the distance covered by each, in Kilometres, was ?

Simple Interest

A sum of money was invested at a certain rate of simple interest for 4 years. Had the sum been invested at a rate 3% higher than the actual rate, the interest earned would have been 720 Rs more. Find the sum initially invested?

Ratio and Proportion

A bag contains red, blue and black balls. The ratio of red to blue balls is 3 : 5. The ratio of black to red balls is 3 : 4. What is the ratio of blue to black balls?

Profit and Loss

Selling a pack of incense sticks for 136 Rs resulted in a loss of 15%. To make a profit of 10%, the selling price should be ?

Percentage

23% of a bucket full of diluted milk was water. If the quantity of pure milk in the bucket was 15.4 liter, then the capacity of the bucket was ?

Average

The average of the marks obtained by three girls in a test was twice the average of the marks obtained by eight boys in that test. If the total marks obtained by all these examinees was 168, find the average marks each of the girls obtained ?

Pipes and Cistern

44 pipes can fill a large water tank in 27 hours. How many hours it take for 66 pipes to fill four such tanks ?

HCF and LCM

A natural number, when divided by 3, 4, 5, 6, and 7 respectively, leaves corresponding remainder of 2, 3, 4, 5 and 6. What is the smallest of all such numbers fulfilling the above condition ?

Coding-Decoding

If in a certain code language, PRINT is written as 34825 and TRUE is written as 5479. Then, how will TENURE be written in that language?

Order Sequence

Arrange the given words from smallest to biggest-
1.Jug
2.Mug
3.Bucket
4.Drum
5.Cup

Statement and Conclusion

Statements
All socks are shoes
Some shoes are black

Conclusions
I. Some shoes are socks.
II. No scoks is black

Numbers

The difference between the place value of 4 and 2 in the number 833749502 is ?

Analogy

GIKM : HJLN :: PRTV : .........?

Order Sequence

In a row of girls, Nanda is eighth from the left and Chanda is nineteenth from right. When Nanda and Chanda interchange their positions, Chanda becomes twnty-third form right. How many girls are there in the row?

Analogy

Summer: Day :: Winter : ........?

Bird:Winges :: Fish:........?