DEV Community

Sharad
Sharad

Posted on

10 Frequently Asked Angularjs Interview Questions

These days AngularJS is one of those hot topics everyone wants to learn it because AngularJs developers are getting more paid by companies. In this article, I going to share 10 Frequently Asked Angularjs Interview Questions and answers

1. What are expressions in Angular?

AngularJs Expressions are used to bind application data to html. Expressions are written inside double braces like . Expressions behave in the same way as ng-bind directives. AngularJS application expressions are pure javascript expressions and output the data where they are used.

2. Do I need Jquery for Angular?

No, you do not need Jquery for Angular. It’s independent of Jquery.

3. What are advantages of MVVM over MVC?

Below are few advantages of MVVM over MVC:-
1.Increases the “Blendability” of your views (ability to use Expression Blend to design views)
2.“Lookless” view logic

  1. No duplicated code to update views
  2. Testability
  3. Designer-Developer Workflow

4. Explain how $scope.$apply() works

$scope.$apply re-evaluates all the declared ng-models and applies the change to any that have been altered (i.e. assigned to a new value)
Explanation: $scope.$apply() is one of the core angular functions that should never be used explicitly, it forces the angular engine to run on all the watched variables and all external variables and apply the changes on their values

5. What is an interceptor? What are common uses of it?

An interceptor is a middleware code where all the $http requests go through.

The interceptor is a factory that are registered in $httpProvider. You have 2 types of requests that go through the interceptor, request and response (with requestError and responseErrorrespectively). This piece of code is very useful for error handling, authentication or middleware in all the requests/responses.

6. Mention what are the advantages of using AngularJS?

There are several advantages of AngularJS, we have listed some below:

  1. AngularJS supports MVC pattern
  2. Can do two ways data binding using AngularJS
  3. It has pre-defined form validations
  4. It supports both client-server communication
  5. It supports animations

7. What is data binding? Explain two-way data binding in AngularJs?

  1. Data binding means automatic synchronous of data between model and view components.

  2. AngularJS supports two-way data binding, it treats the model as a single source of truth and view is a projection of model. It means when we change model view gets reflect and vice-versa.

  3. In traditional concept, HTML pages are decided by interacting with server-side program and as we using single page application, pages are decided without any server-side interaction. So required part of the page will be updated.

8. Distinguish between AngularJS expression & JavaScript expression?

AngularJS expression:

  1. Expressions are evaluated against $scope.

  2. Expression evaluation is forgiving to null and undefined.

  3. In AngularJS, loops, conditions and exceptions are not required to write.

  4. AngularJS supports filters to format data before displaying.

JavaScript Expression:

  1. Expressions are evaluated against Window object.

  2. Undefined properties generates Type Error or Reference Error

  3. In AngularJS, loops, conditions and exceptions are required to write.

  4. No such a feature.

9. What is a model in AngularJs?

  1. Model is JavaScript object and it binds view data into the model through the directives such as text field, text area and selects etc.

  2. It provides validation behaviors by required, number, URL, email, min and max length etc.

10. Distinguish between factory, service & provider?

Factory:

When you’re using a Factory you create an object, add properties to it, then return that same object. When you pass this service into your controller, those properties on the object will now be available in that controller through your factory.

Service:

When you’re using Service, it’s instantiated with the ‘new’ keyword. Because of that, you’ll add properties to ‘this’ and the service will return ‘this’. When you pass the service into your controller, those properties on ‘this’ will now be available on that controller through your service.

Providers:

Providers are the only service you can pass into your .config() function. Use a provider when you want to provide module-wide configuration for your service object before making it available.

Read More from https://www.onlineinterviewquestions.com/angular-js-interview-questions/

Top comments (4)

Collapse
 
hemantgola2 profile image
Hemant Gola

Hi @Sharad Angular is one of the most trendings Web framework nowadays, and many of the leading tech companies use angular, you can also find approx 50+ Angular Interview Questions here:
techgeekbuzz.com/angular-interview...

Collapse
 
jhonsmith03 profile image
jhonsmith03

Hi Sharad,

Thanks for providing 10 frequently questions about Angularjs interview.

It'll help students to crack interviewed easily after reading this, but I had read few more questions that also might help students.
Source: bit.ly/angularjs-interview-questions

Collapse
 
aershov24 profile image
Alex 👨🏼‍💻FullStack.Cafe

Thanks for the great post Sharad! Your interview questions and answers have been added to fullstack.cafe portal and back-linked!

Collapse
 
vijaykhatri96 profile image
Vijay Singh Khatri

Hi @sharad,
Here you have listed only 10 question, get more question from here: hackr.io/blog/angular-interview-qu...