AngularJS Interview Questions Interview Questions


AngularJS Interview Questions and Answers

1. What is AngularJS?

AngularJS is an open-source JavaScript framework, maintained by Google, that assists with running single-page applications. Its goal is to augment browser-based applications with model–view–controller capability, in an effort to make both development and testing easier.
AngularJS Interview Questions and Answers

2. Can you please explain what is testability like in Angular?

Very testable and designed this way from ground up. It has an integrated dependency injection framework, provides mocks for many heavy dependencies (server-side communication).

3. Tell me 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.

4. Tell me can we use the open-source Closure Library with Angular?

Yes, you can use widgets from the Closure Library in Angular.

5. Do you know what is Angulars performance like?

The startup time heavily depends on your network connection, state of the cache, browser used and available hardware, but typically we measure bootstrap time in tens or hundreds of milliseconds.

The runtime performance will vary depending on the number and complexity of bindings on the page as well as the speed of your backend (for apps that fetch data from the backend). Just for an illustration we typically build snappy apps with hundreds or thousands of active bindings.

6. Tell me which browsers does Angular work with?

We run our extensive test suite against the following browsers: Safari, Chrome, Firefox, Opera, IE8, IE9 and mobile browsers (Android, Chrome Mobile, iOS Safari). See Internet Explorer Compatibility for more details in supporting legacy IE browsers.

7. What is ng-app in AngularJS?

To initialize the Angular Application.

8. What is ng-init in AngularJS?

To initialize the Angular Application data.

9. In which language, AngularJS is written?


10. When First AngularJS was released?

AngularJS was released in 2009.

11. When latest AngularJS was released?

October 31, 2014.

12. What is latest version of AngularJS?


13. Is it opensource?

Yes, It is free to use.

14. What are the key features of Angular.js?

  • Scope
  • Controller
  • Model
  • View
  • Services
  • Data Binding
  • Directives
  • Filters
  • Testable

15. What is controller in AngularJS?

Controller is constructor function in Angular Controller. When a Controller is attached to the DOM with use the ng-controller, Angular will instantiate a new Controller object using constructor function.

16. What are directives?

Directives are used to add new attributes of HTML.

17. What are the different types of Directives?

Different types of directives are:

  • Element directives
  • Attribute directives
  • CSS class directives
  • Comment directives

18. What is injector?

An injector is a service locator, used to retrieve object instances.

19. What are factory method in angularJs?

Factory method are used to create the directive. It is invoked only once, when compiler matches the directive for the first time.

20. What is ng-model in AngularJS?

To bind the html tags (input, select, textarea) to Angular Application Data.
AngularJS Interview Questions and Answers PDF

AngularJS Interview Questions and Answers for Experienced PDF:

21. What is Data Binding in Angular JS?

It is synchronization of data between the model(Angular Application variable) and view components (display with {{}}).

22. How to initiate variable in AngularJS?

<div ng-app=”” ng-init=”quantity=10;cost=5″>
<b>Total Cost: {{ quantity * cost }}</b>

23. Does Angular use the jQuery library?

Yes, Angular can use jQuery if you have included the jQuery library.
IF Not, Angular falls back to its own implementation of the subset of jQuery that we call jQLite.

24. Give an Example of Data-Binding in AngularJS?

<div ng-app=”” ng-init=”quantity=10;cost=5″ class=”ng-scope”>
<b class=”ng-binding”>Total Cost: 50</b>

25. What is Looping in AngularJs?

It is used to display the data in loop same as foreach in PHP.

26. How to Write Expression in AngularJS?

<div ng-app=””>
<b>Expression: {{ 15 + 55 }}</b>

27. Example of AngularJS Strings?

<div ng-app=”” ng-init=”Str1=’Web’;Str2=’Technology'”>
Full String is : <b>{{ Str1 + ” ” + Str2 }}</b>

28. Example of AngularJS Object?

<div ng-app=”” ng-init=”myobj={Str1:’Web’,Str2:’Technology’}”>
String Display: <b>{{ myobj.Str2 }}</b></div>

29. What is Angular Controllers?

Controller is constructor function in Angular Controller.
When a Controller is attached to the DOM with use the ng-controller, Angular will instantiate a new Controller object using constructor function.

30. Do you know 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.

31. Do you know 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.

32. What is Context in AngularJS?

In Angular, the expressions are evaluated against a scope object, while the Javascript expressions are evaluated against the global window.

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

34. What is Forgiving in AngularJS?

In Angular expression evaluation is forgiving to null and undefined, while in Javascript undefined properties generates TypeError or ReferenceError.

35. What is “No Control Flow Statements” in AngularJS?

Loops, conditionals or exceptions cannot be used in an angular expression.

AngularJS Interview Questions for Experienced PDF Download

Watch AngularJS full tutorial at Youtube

36. Tell me 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-switchOn = “! ! accounts” ng-init = ” loadData ( ) “>

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

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

39. What is registering callbacks in AngularJS?

There is no need to register callbacks . This makes your code simple and easy to debug.

40. What is “control HTML DOM programmatically” in AngularJS?

All the application that are created using Angular never have to manipulate the DOM although it can be done if it is required.

41. What is “Transfer data to and from the UI” in AngularJS?

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.

42. What is “no initilization code” in AngularJS?

With angular.js you can bootstrap your app easily using services, which auto-injected into your application in Guice like dependency injection style.

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

44. On what 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.

45. What is 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.

46. What is Pre-linking function in AngularJS?

Pre-linking function is executed before the child elements are linked. It is not considered as the safe way for DOM transformation.

47. What is Post linking function in AngularJS?

Post linking function is executed after the child elements are linked. It is safe to do DOM transformation by post-linking function.

AngularJS Interview Questions PDF Download

48. What is Compile function in AngularJS?

It is used for template DOM Manipulation and collect all of the directives.

49. What is Link function in AngularJS?

It is used for registering DOM listeners as well as instance DOM manipulation. It is executed once the template has been cloned.

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

51. 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
  • ng-pristine
  • ng-dirty

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

53. What is dependency injection in AngularJS?

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.

54. How an object or function can get a hold of its dependencies?

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.

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

56. Can you please explain 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.

57. What are the concept of scope hierarchy? Tell me 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.