Angular Js Interview Questions and Answers for Freshers, Experienced

“AngularJS is a JavaScript framework which simplifies binding JavaScript objects with HTML UI elements”. It follows MVC (Model View Controller) pattern and enables you to extend HTML’s syntax to express your application’s components clearly.

Below are some of the features supported in C# -

  • • Allows Us to Create Single Page Application
  • • Supports Two Way Data Binding
  • • Cross Browser Compliant
  • • Supports Animation
  • • Its Code are Unit Testable
  • • Follows MVC Pattern
  • • Predefined Form Validations
  • • Open Source
  • • MVC
  • • Modules
  • • Validations
  • • Directives
  • • Templates
  • • Scope
  • • Expressions
  • • Data Binding
  • • Filters
  • • Services
  • • Routing
  • • Testing

Data Binding is the automatic synchronization of data between model and view. There are two ways of data binding:

  • • One way data binding (used in classical template)
  • • Two way data binding (used in AngularJS template)

Scopes are objects that refer to the model. Each AngularJS application can have only one root scope but can have multiple child scopes.

Controllers are JavaScript functions that are bound to a particular scope and logic to HTML UI. It acts as an interface between Server and HTML UI.

Services are objects that can be used to store and share data across the application. AngularJS offers many built-in services such as $http i.e. used to make XMLHttpRequest.

Filters select a subset of items from an array and return a new array. Filters are used to show filtered items from a list of items based on defined criteria.

Directives are markers on DOM elements (such as elements, attributes, css, and more).All AngularJS directives start with the word "ng". There are many in-built directives in AngularJS such as "ng-app", "ng-model", "ng-controller", "ng-repeat" etc.

Templates are the rendered view with information from the controller and model. These can be a single file (like index.html) or multiple views in one page using "partials".

ng-app directive defines and links an AngularJS application to HTML. It also indicate the start of the application.

ng-model directive binds the values of AngularJS application data to HTML input controls. It creates a model variable which can be used with the html page and within the container control( for example, div) having ng-app directive.

Expressions are used to bind application data to html. Expressions are written inside double braces like {{ 3+4}}. Expressions behave in same way as ng-bind directives. AngularJS application expressions are pure JavaScript expressions and outputs the data where they are used.

  • • One way binding implies that the scope variable in the html will be set to the first value its model is bound to (i.e. assigned to).
  • • Two way binding implies that the scope variable will change it’s value everytime its model is assigned to a different value.

AngularJS directives are extended HTML attributes with the prefix ng-.

  • The ng-app directive initializes an AngularJS application.
  • The ng-init directive initializes application data.
  • The ng-model directive binds the value of HTML controls (input, select, textarea) to application data.

AngularJS enriches form filling and validation. We can use $dirty and $invalid flags to do the validations in seamless way. Use novalidate with a form declaration to disable any browser specific validation.

Following can be used to track error.
  • • $dirty − states that value has been changed.
  • • $invalid − states that value entered is invalid.
  • • $error − states the exact error.

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 responseError respectively). This piece of code is very useful for error handling, authentication or middleware in all the requests/responses.

Factory method is used to define a factory which can later be used to create services as and when required whereas service method is used to create a service whose purpose is to do some defined task.

The $routeProvider is used to configure roots within an AngularJS application. It can be used to link a url with a corresponding HTML page or template, and a controller (if applicable).

Deep linking allows you to encode the state of application in the URL so that it can be bookmarked. The application can then be restored from the URL to the same state.

Stay Connected

Popular Posts

Get Latest Stuff Through Email

Who Should Read TechTrick?

All the tricks and tips that TechTrick provides only for educational purpose. If you choose to use the information in TechTrick to break into computer systems maliciously and without authorization, you are on your own. Neither I (TechTrick Admin) nor anyone else associated with TechTrick shall be liable. We are not responsibe for any issues that caused due to informations provided here. So, Try yourself and see the results. You are not losing anything by trying... We are humans, Mistakes are quite natural. Here on TechTrick also have many mistakes..