AngularJs Interview Questions

angularjs interview questions

AngularJS Interview Questions

1. Name the key features of AngularJS?

The key features of AngularJS are:

  • Scope
  • Controller
  • Model
  • View
  • Services
    • Build in services
    • Custom services
  • Data Binding
    • One-way Data Binding
    • Two-way Data Binding
  • Directives
    • Build in Directives
    • Custom Directives
  • Filters
    • Build in filter
    • Custom filters
  • Routing
  • Forms
    • Form validations
  • Dependency Injection
  • Testable

2. Explain data binding in AngularJS.

According to AngularJS.org, “Data-binding in Angular apps is the automatic synchronization of data between the model and view components. The way that Angular implements data-binding lets you treat the model as the single-source-of-truth in your application. The view is a projection of the model at all times. When the model changes, the view reflects the change and vice versa.”

There are two ways of data binding:

  1. One- way Data Binding
    1. One – way data binding model to view and this binding performed by property, we can call it property binding.

 

  1. Two – way Data Binding

Two– way data binding model to view and view to model this binding performed by the event, we can call it as event binding.

3. What are directives in AngularJS?

Directives are extended of an HTML attributes with the prefix ng-

Like:-

ng-appà to initialization the angular app

ng-controllerà to control the angular app

ng-inità to initialization the values.

ng-modelà to bind the HTML controls(inputs, select,…);

ng-repeatà to repeat the data like loops.

ng-bindà to bind the HTML content

ng-show,ng-hide,ng-click….etc

4. What are Controllers in AngularJS?

Controllers are Javascript functions which provide data and logic to HTML UI. The controller controls the angular app.usning ng-controller directive.

Creation angular js Controller

app=angular.module(“myApp”,[]);

appp.controller(“myCtrl”,function(){

$scope.a=10;

})

5. What is Angular Expression? How do you differentiate between Angular expressions and JavaScript expressions?

Angular expressions are code snippets that are usually placed in binding such as {{ expression }} similar to JavaScript.

The main differences between Angular expressions and JavaScript expressions are:

  • Context: The expressions are evaluated against a scope object in Angular, while Javascript expressions are evaluated against the global window
  • Forgiving: In the Angular expression, the evaluation is forgiving to null and undefined whereas in JavaScript undefined properties generate TypeError or ReferenceError
  • No Control Flow Statements: We cannot use loops, conditionals or exceptions in an Angular expression
  • Filters: In Angular, unlike JavaScript, we can use filters to format data before displaying it

angularjs interview questions

6. 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.

7. What are the characteristics of ‘Scope’?

A scope is an object that refers to the application model. It is an execution context for expressions. Scopes are arranged in a hierarchical structure which mimics the DOM structure of the application. It can watch expressions and propagate events.

The characteristics of Scope are:

  • Provides APIs ($watch) to observe model mutations.
  • Scopes provide APIs ($apply) to propagate any model changes through the system into the view from outside of the “Angular realm” (controllers, services, Angular event handlers).
  • Scopes can be nested to limit access to the properties of application components while providing access to shared model properties. Nested scopes are either “child scopes” or “isolate scopes”. A “child scope” (prototypically) inherits properties from its parent scope. An “isolate scope” does not. See isolated scopes for more information.
  • Scopes provide a context against which expressions are evaluated. For example, {{username}} expression is meaningless, unless it is evaluated against a specific scope which defines the username property.

8. What are the advantages of using an Angular.js framework?

Angular.js framework has the following advantages:

  • Supports two-way data-binding
  • Supports MVC pattern
  • It Supports searching using filters
  • Support routing
  • Support static template and angular template
  • Can add a custom directive
  • Supports REST-full services
  • Supports form validations
  • Support both client and server communication
  • Support dependency injection
  • Applying Animations
  • Event Handlers

9. What is the difference between AngularJS and backbone.js?

AngularJS combines the functionalities of most third-party libraries and supports individual functionalities required to develop HTML5 Apps.  While Backbone.js does these jobs individually.

To Learn Complete AngularJS with Project from Real-Time Expert fill details.



10. Explain what is injector in AngularJS?

An injector is a service locator, used to single $injector to invoke controller functions, service functions, filter functions, and any other function that might need dependencies as parameters.

 

For HTML Interview Questions Click Here

Please follow and like us:
500

Leave a Reply

Your email address will not be published. Required fields are marked *