Friday, 27 January 2017


31. Does Angular use the jQuery library?


YES, Angular can use jQuery if it’s present in your app when the application is being bootstrapped. If jQuery is not present in your script path, Angular falls back to its own implementation of the subset of jQuery that we call jQLite.

32. Why AngularJS?


AngularJS lets you extend HTML vocabulary for your application. The resulting environment is extraordinarily expressive, readable, and quick to develop.
MVC implementation is done right.
It extends HTML using directives, expression and data binding techniques to define a powerful HTML template.
Two way data-binding, form validations, routing supports, inbuilt services.
REST friendly.
Dependency injection support.
It helps you to structure and test your JavaScript code.

33. What are the key features/concepts of Angular.js?

When you start learning AngularJS, you will come across following terms and these are the features/concept of AngularJS.
Data Bindings
Dependency Injection

Here you can find more topics about the AngularJS Concepts.

34. Is AngularJS is compatible with all modern browsers?

 YES. AngularJS team run extensive test suite against the following browsers: Safari, Chrome, Firefox, Opera 15, IE9 and mobile browsers (Android, Chrome Mobile, iOS Safari).

35.What is the basic need to start with AngularJS?


To start with AngularJS, one need to make reference of angular.js. The latest version of AngularJS can be downloaded from You can either download the required js file and then host them locally or you can also use google CDN for referencing it. Here is the link for google CDN url for referencing AngularJS.

36. How does the AngularJS framework initialize itself?


The AngularJS has a self-executing anonymous function present in angular.js code, which does the initialization of AngularJS.
Here is how below it looks:
(function(window, document, undefined) {
here goes entire AngularJS code
including functions, services, providers etc related code goes here
if (window.angular.bootstrap) {
    //AngularJS is already loaded, so we can return here...
    console.log('WARNING: Tried to load angular more than once.');
  //try to bind to jquery now so that one can write angular.element().read()
  //but we will rebind on bootstrap again.
  jqLite(document).ready(function() {
    angularInit(document, bootstrap);
})(window, document);
Above function first check if Angular has already been setup. If it has, we return here to prevent Angular from trying to initialize itself a second time. And then it binds jQuery (if present) and publish external API. And finally angularInit() method does the trick for initialization of AngularJS.

37. What is the bootstrapping in AngularJS?

Bootstrapping in AngularJS is nothing but just initializing, or starting, your Angular app. AngularJS supports automatic bootstrapping as well as manual way as well.

 38. What are templates in AngularJS?


In Angular, templates are written with HTML that contains Angular-specific elements and attributes. Angular combines the template with information from the model and controller to render the dynamic view that a user sees in the browser. In other words, if your HTML page is having some Angular specific elements/attributes it becomes a template in AngularJS.


39. What are directives in AngularJS?


Directives are markers on a DOM element (such as an attribute, element name, comment or CSS class) that tell AngularJS to attach a specified behavior to that DOM element or even transform the DOM element and its children. When AngularJS finds the directive at the time of rendering then it attaches the requested behavior to the DOM element. Angular comes with a set of these directives built-in, like ngBind, ngModel, and ngClass.

40. Can we create our own directives?


YES. AngularJS allows us to create our own custom directive.

To know more about the Angularjs Course details, Please visit Best Angularjs Training.

Thursday, 26 January 2017

AngularJS – State Management using State Providers

AngularJS framework is a best way to create single page applications. In our application routing is an important concept and when it comes to a single page application we need to ensure that UI-Routing should behave like navigation.

Different Types of Routing

We can do routing in AngularJS by two ways,

  • ng Route method
  • UI-Router method

Let’s understand how UI-Router method is different from normal ng-Route method.

Overview – UI Router 

AngularJS provides a UI Routing inbuilt within the framework. UI Router approach is different from the normal ng-Route method where navigation of application is based on route URL. In UI Route navigation of application is based on the State of the application.

We have to think user action as state to implement UI-Route State Management approach. In Navigation Menu each link is a state, Subscribe button click can be a state; Modal Pop-up in our application can be a state.

Understand UI-Route Implementation

Let’s start with creating a small application, and configure UI-Route for our Navigation Menu. In UI-Router we link to a State not to a URL.

Files required,

  • Index.html
  • jquery.min.js
  • angular.min.js
  • angular-ui-router.min.js
  • app.js

Create Index file.

Create a HTML file; I have my file named – index.html. In my index file I will be having header with navigation menu.

<!doctype html>
    <title>State provider and Ui-Router example </title>
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/angular.min.js"></script>
    <script type="text/javascript" src="js/angular-ui-router.min.js"></script>
    <script type="text/javascript" src="js/app.js"></script>
    <li><a ui-sref="home" ui-sref-active="active">Home</a></li>
    <li><a ui-sref="about" ui-sref-active="active">About</a></li>
    <li><a ui-sref="services" ui-sref-active="active">Services</a></li>
    <li><a ui-sref="contact" ui-sref-active="active">Contact</a></li>
</ul> </nav>

 Apart from our regular AngularJS files, we need app.js to define the UI-route configurations.

<a ui-sref="home">Home</a>  

Notice how the above code will be changed in our browser, and href will be generated with a URL value.

<a href="/ home" ui-sref="home">Home</a>

Configure State in Angular app

We will be configuring the states required for our application in app.js. We should remember that we are configuring STATES not with URL.

Let’s create a Navigation Menu; we have 4 navigation links – Home, About, Services and Contact. In this scenario each link will be a state.

In our app.js you will be able to understand how states are mapped for each navigation link.

// app.js
var routerApp = angular.module('stateRouterApp', ['ui.router']);
'stateRouterApp'.config(function($stateProvider, $urlRouterProvider) {
        .state('home', {
            url: '/home',
            templateUrl: index.html'
      .state('about', {  //nested link in home page
        url: '/about,
        templateUrl: ‘/about.html’
       .state('services', {  //nested link in home page
        url: '/ services’,
        templateUrl: ‘/services.html’
.state('contact', {  //nested link in home page
        url: '/ contact’,
        templateUrl: ‘/contact.html’

Understanding the parameters of app.js UI-Route,

state('home') – State parameter is mapped in navigation link using ui-sref="home"

url: '/index’ -  URL parameter is a URL which will be changed in anchor link ‘href’ attribute.

templateUrl: ‘/home.html’ – templateUrl parameter is a important parameter which will provide the actual content for each state.

Inject Angular App in Page

We have to inject the state content when we click on each navigation link, which can achieved using below tag,

Ui-view - <div ui-view></div>. 
We will be using ui-view instead of ng-route - <div ng-view></div>

  <body ng-app="stateRouterApp" >
    <li><a ui-sref="home" ui-sref-active="active">Home</a></li>
    <li><a ui-sref="about" ui-sref-active="active">About</a></li>
    <li><a ui-sref="services" ui-sref-active="active">Services</a></li>
    <li><a ui-sref="contact" ui-sref-active="active">Contact</a></li>
</ul> </nav>
<div class="container">
    <!—Our content will be injected below  -->
    <div ui-view></div>

When we click on each navigation link (Home, About, Services, Contact) relevant content will be loaded in ‘<div ui-view></div>’.

Wrapping up

So we understand UI-Router works with states not with URL. This will help you to build better AngularJS applications. If you have a moment, please share your feedback/comments or any queries about UI-Router.

I will be sharing more articles on advantages of Staterpovider in AngularJS ,

  • URL Parameters with States
  • Classes Based on Current State
  • Creating Modal Pop-up
  • Multiple Views

To Know more about the AngularJS Course, Visit our Main Website - Best AngularJS Training

Thursday, 19 January 2017


To Know more about the trending framework AngularJS, Visit AngularJS Training

21. Mention what are the characteristics of “Scope”?

To observer model mutations scopes provide APIs ($watch)
To propagate any model changes through the system into the view from outside of the Angular realm
A scope inherits properties from its parent scope, while providing access to shared model properties, scopes can be nested to isolate application components.
Scope provides context against which expressions are evaluated

22. Explain what is DI (Dependency Injection ) and how an object or function can get a hold of its dependencies ?

DI or Dependency Injection is a software design pattern that deals with how code gets hold of its dependencies. In order to retrieve elements of the application which is required to be configured when module gets loaded , the operation “config” uses dependency injection.

These are the ways that object uses to hold of its dependencies:
Typically using the new operator, dependency can be created
By referring to a global variable, dependency can be looked up
Dependency can be passed into where it is required

23. Mention what are the advantages of using Angular.js framework?


Advantages of using Angular.js as framework are:
Supports two way data-binding
=>Supports MVC pattern
=>Support static template and angular template
=>Can add custom directive
=>Supports REST full services
=>Supports form validations
=>Support both client and server communication
=>Support dependency injection
=>Applying Animations
=>Event Handlers



 24. Explain the concept of scope hierarchy? How many scope can an application have?


Each angular application consist of one root scope but may have several child scopes. As child controllers and some directives create new child scopes, application can have multiple scopes. When new scopes are formed or created they are added as a children of their parent scope. Similar to DOM, they also creates a hierarchical structure.

25. Explain what is the difference between angular.js and backbone.js?


Angular.js combines the functionalities of most of the 3rd party libraries, it supports individual functionalities required to develop HTML5 Apps. While Backbone.js do their jobs individually.

26. Who created Angular JS ?


Intially it was developed by Misko Hevery and Adam Abrons. Currently it is being developed by Google.

27. What is Angular.js?


AngularJS is open source client side MV* (Model – View – Whatever) framework for creating dynamic web applications. It gives life to your static HTML and makes it dynamic with its magic. It extends HTML using directives, expression and data binding techniques to define a powerful HTML template.

28. Is AngularJS a framework, library or a plugin?


The suitable answer is that its a framework. As its lightweight so people also get confused between library and framework.AngularJS is open source client side MVC framework for creating dynamic web applications.

29. Is it same as jQuery?

NO. jQuery is great library for manipulating the DOM, providing better user experience with animations and effects. You can create website using jQuery but not a web application. jQuery is just a library to play around with HTML, where as AngularJS is a framework to build a dynamic web app as it supports two data binding, MVC, allow testability, templates and many more. Its like AngularJS like a toolbox and jQuery is just a tool.

30. How can we decrease digest cycle time ?

To decrease digest cycle time you need to decrease the number of watchers.

Below are some best practices you can follow to decrease number of watchers :-
=> Remove unnecessary watchers.
=> Use one time Angular binding. Especially if you see ng-repeat loop apply one time binding.
=> Work in batches.
=> Cache DOM
=> Use Web worker.
To Know more about the trending framework AngularJS, Visit AngularJS Training


To Know more about the trending framework AngularJS, Visit Best AngularJS Training in Chennai

11. What makes angular.js better ?

Registering Callbacks: There is no need to register callbacks . This makes your code simple and easy to debug.
Control HTML DOM programmatically: All the application that are created using Angular never have to manipulate the DOM although it can be done if it is required.
Transfer data to and from the UI: Angular.js helps to eliminate almost all of the boiler plate like validating the form, displaying validation errors, returning to an internal model and so on which occurs due to flow of marshalling data.
No initilization code: With angular.js you can bootstrap your app easily using services, which auto-injected into your application in Guice like dependency injection style.

12. Is AngularJS extensible?

Yes! In AngularJS we can create custom directive to extend AngularJS existing functionalities.
Custom directives are used in AngularJS to extend the functionality of HTML. Custom directives are defined using “directive” function. A custom directive simply replaces the element for which it is activated. AngularJS application during bootstrap finds the matching elements and do one time activity using its compile() method of the custom directive then process the element using link() method of the custom directive based on the scope of the directive.

13. Explain what is string interpolation in angular.js ?

In angular.js the compiler during the compilation process matches text and attributes using interpolate service to see if they contains embedded expressions. As part of normal digest cycle these expressions are updated and registered as watches.

14. Mention the steps for the compilation process of HTML happens?

Compilation of HTML process occurs in following ways:-
=> Using the standard browser API, first the HTML is parsed into DOM
=> By using the call to the $compile () method, compilation of the DOM is performed. The method traverses the DOM and matches the directives.
=> Link the template with scope by calling the linking function returned from the previous step.

15. Explain what is directive and Mention what are the different types of Directive?

During compilation process when specific HTML constructs are encountered a behaviour or function is triggered, this function is referred as directive. It is executed when the compiler encounters it in the DOM.
Different types of directives are:-
=> Element directives
=> Attribute directives
=> CSS class directives
=> Comment directives

16. Explain what is linking function and type of linking function?

Link combines the directives with a scope and produce a live view. For registering DOM listeners as well as updating the DOM, link function is responsible. After the template is cloned it is executed.
Pre-linking function: Pre-linking function is executed before the child elements are linked. It is not considered as the safe way for DOM transformation.
Post linking function: Post linking function is executed after the child elements are linked. It is safe to do DOM transformation by post-linking function.

17. Explain what is injector?

An injector is a service locator. It is used to retrieve object instances as defined by provider, instantiate types, invoke methods and load modules. There is a single injector per Angular application, it helps to look up an object instance by its name.

18. Explain what is the difference between link and compile in angular.js?

Compile function: It is used for template DOM Manipulation and collect all of the directives.
Link function: It is used for registering DOM listeners as well as instance DOM manipulation. It is executed once the template has been cloned.

19. Explain what is factory method in angular.js?

For creating the directive, factory method is used. It is invoked only once, when compiler matches the directive for the first time. By using $injector.invoke the factory method is invoked.

20. Mention what are the styling form that ngModel adds to CSS classes ?

ngModel adds these CSS classes to allow styling of form as well as control:
ng- valid
ng- invalid

TTo Know more about the trending framework AngularJS, Visit Best AngularJS Training in Chennai

Wednesday, 11 January 2017


Here is the Top 10 Interview questions of Angurlarjs.

To Know more about the trending framework AngularJS, Visit

1. What is Angular.js?

AngularJS is open source client side MV* (Model – View – Whatever) framework for creating dynamic web applications. It gives life to your static HTML and makes it dynamic with its magic. It extends HTML using directives, expression and data binding techniques to define a powerful HTML template.

2. Explain what are the key features of Angular.js ?

The key features of angular.js are:
=> Scope
=> Controller
=> Model
=> View
=> Services
=> Data Binding
=> Directives
=> Filters
=> Testable

3. Explain what is scope in Angular.js ?

Scope refers to the application model, it acts like glue between application controller and the view. Scopes are arranged in hierarchical structure and impersonate the DOM ( Document Object Model) structure of the application. It can watch expressions and propagate events.

4. Explain what is services in Angular.js ?

In angular.js services are the singleton objects or functions that are used for carrying out specific tasks. It holds some business logic and these function can be called as controllers, directive, filters and so on.

5. Explain what is Angular Expression? Explain what is key difference between angular expressions and JavaScript expressions?


Like JavaScript, Angular expressions are code snippets that are usually placed in binding such as {{ expression }}
The key difference between the JavaScript expressions and Angular expressions:-
Context : In Angular, the expressions are evaluated against a scope object, while the Javascript expressions are evaluated against the global window
Forgiving: In Angular expression evaluation is forgiving to null and undefined, while in Javascript undefined properties generates TypeError or ReferenceError
No Control Flow Statements: Loops, conditionals or exceptions cannot be used in an angular expression
Filters: To format data before displaying it you can use filters

6. With options on page load how you can initialize a select box ?

You can initialize a select box with options on page load by using ng-init directive
<div ng-controller = “ apps/dashboard/account ” ng-switch
On = “! ! accounts” ng-init = “ loadData ( ) ”>

7. Explain what are directives ? Mention some of the most commonly used directives in Angular.js application ?

A directive is something that introduces new syntax, they are like markers on DOM element which attaches a special behavior to it. In any Angular.js application, directives are the most important components.
Some of the commonly used directives are ng-model, ng-App, ng-bind, ng-repeat , ng-show etc.

8. Mention what are the advantages of using Angular.js ?

Angular.js has several advantages in web development.
=> Angular.js supports MVS pattern
=> Can do two ways data binding using Angular.js
=> It has per-defined form validations
=> It supports both client server communication
=> It supports animations

9. Explain what Angular JS routes does ?

Angular js routes enable you to create different URLs for different content in your application. Different URLs for different content enables user to bookmark URLs to specific content. Each such bookmarkable URL in Angular.js is called a route.
A value in Angular JS is a simple object. It can be a number, string or JavaScript object. Values are typically used as configuration injected into factories, services or controllers. A value should be belong to an Angular.js module.
Injecting a value into an Angular.js controller function is done by adding a parameter with the same name as the value

10. Explain what is data binding in Angular.js ?

Automatic synchronization of data between the model and view components is referred as data binding in Angular.js. There are two ways for data binding:-
=> Data mining in classical template systems
=> Data binding in angular templates

For more info visit AngularJS Training