Angularjs interview questions and answers for freshers

 

Find what are templates in AngularJS?

Template is created with HTML that contains Angular specific attribute and element. In Angular combines the template with information from the model and different type controller to render the dynamic view that a user look in the browser. We can say that, if your HTML page is having some Angular specific attributes and elements it becomes a template in AngularJS.

Explain what is routing in AngularJS?

In AngularJS the routing provide concept of switching views. The AngularJS based controller decides which view to render based on the most business logic.

What is controller in AngularJS?

In AngularJS the controller is responsible for construction of the design and different type model connects it to the view. So, the scope sits between the controller and the view. The controllers should be straightforward and easily understandable the business logic need for a view. Basically you want thin controllers and rich services.

Explain why to use AngularJS?

There are various reasons to choose AngularJS as web development framework:

  • AngularJS is based on MVC pattern which provide you to organize your several web applications properly.
  • AngularJS extends HTML by adding directives to your HTML markup with new attribute/element or tags and expressions.

What is Model in AngularJS?

A model is generally a JavaScript object. No need to extend anything or define any structure. It provides for nested models something that backbone does not do out of the box.

Mention how AngularJS is different from other JavaScript framework?

We can say that, today AngularJS is the most famous and popular and dominant JavaScript framework for professional web development. So, it is well suited for small, large and any size web application.

READ  AngularJS Views and Directives

AngularJS is different from other JavaScript framework in several ways:

  • It uses plain old JavaScript objects (POJO)
  • It is leverages with DI (Dependency Injection).
  • It is markup lives in the DOM.

Find who is developed AngularJS?

AngularJS is developed by the Misko Hevery. He was employee of google.

Mention what is ng-model in AgularJS?

In AngularJS the ng-model provides to bind the html tags (input, select, textarea) to AngularJS Application Data.

Mention which IDEs can use for AngularJS development?

An AngularJS development can be done with the help of various IDEs:

  • WebStorm
  • Eclipse
  • Visual Studio 2012, 2013, 2015 or higher
  • TextMate
  • Sublime Text

Finding how to check validate data in AngularJS?

AngularJS enhance form filing and validation. So, we can use $dirty and $invalid flags to do the validations in logical way. Use of no validate with a form declaration to disable any browser specific validation. There are following can be used to track error.

  • $invalid: it provides value entered is invalid.
  • $dirty: It provides value has been changed.
  • $error: It provides the exact error.

Mention when first AngularJS was released?

The first AngularJS was released in 2009.

Explain what is jQLite or jQuery lite?

The jQLite is a subset of jQuery that is make directly into AngularJS. The jQLite allows you all the very useful features of jQuery. So, in fact it given you limited features or functions of jQuery.

What is $watch and $apply in AngularJS?

AnngularJS two-way data binding is the root of all awesome in AngularJS. But, it is not magic, and there are some situations where you need to give it a nudge in the right direction. When you bind a value to an element in AngularJS utilizing the ng-model, ng-repeat etc., Angular creates a $watch on that value.

READ  AngularJS Ajax calls

Find is AngularJS a library, framework, plugin or a browser extension?

AngularJS is a first class JavaScript framework which provides you to make well structured easily maintainable and testable front end applications. We can say that, it is not a library provides you limited functionality has dependencies to other libraries. AngularJS is not plugin or browser extension since it is based on JavaScript and compatible with both browsers desktop and mobile.

Mention what is the size of AngularJS file?

The size of the compressed and minifiled file is greater than 36KB.

Explain what is provider and give some example?

A provider is used by the AngularJS internally to create factory, services and so on at the time of config phase. Here give some example through mention script can be used to define MtheService that we have created earlier. It is a special factory method get() which is used to return the service, factory and value.

 

//define a module
var mainApp = angular.module("mainApp", []);
...
mainApp.config(function($provide) {
   $provide.provider('MathService', function() {
 
      this.$get = function() {
         var factory = {}; 
         factory.multiply = function(a, b) {
            return a * b;
         }
         return factory;
      };
 
   });
});

Mention how to handle the security in AngularJS?

AngularJS provide the various built in protection from basic security holes:

  • Prevent HTML injection attacks.
  • Prevent Cross site Scripting (CSS) attacks
  • Prevent XSRF protection for server side communication

AngularJS is created to be compatible with other security measures such as, content Security Policy (CSP), HTTPS (SSL/TLS) and server side authentication that greatly reduce the possible attacks.