Wednesday 28 June 2017

AngularJS

AngularJS Interview Questions & Answers:

1) What is AngularJS?
AngularJS is a javascript framework used for creating single web page applications.  It allows to use HTML as your template language and enables you to extend HTML’s syntax to express your application’s components clearly.

2) Explain what are the key features of AngularJS ?
The key features of AngularJS are

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

3) Explain what is scope in AngularJS ?
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 AngularJS ?
In AngularJS 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

On = “! ! accounts” ng-init = “ loadData ( ) ”>


7) Explain what are directives ? Mention some of the most commonly used directives in AngularJS 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 AngularJS 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 AngularJS ?
AngularJS has several advantages in web development.

AngularJS supports MVC pattern
Can do two ways data binding using AngularJS
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 AngularJS 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 AngularJS module.

Injecting a value into an AngularJS controller function is done by adding a parameter with the same name as the value

10)  Explain what is data binding in AngularJS ?
Automatic synchronization of data between the model and view components is referred as data binding in AngularJS.  There are two ways for data binding

Data mining in classical template systems
Data binding in angular templates

11)  What makes AngularJS 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: AngularJS 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 AngularJS you can bootstrap your app easily using services, which auto-injected into your application in Guice like dependency injection style

12)  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.

13)  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

14)  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

15)  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

16)  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.

17)  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.

18)  Explain what is factory method in AngularJS?
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.

19)  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
ng-pristine
ng-dirty

20)  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

21)  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

22)  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

23)  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.

24)  Explain what is the difference between AngularJS and backbone.js?
AngularJS 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.

25)  Who created Angular JS ?
Intially it was developed by Misko Hevery and Adam Abrons. Currently it is being developed by Google.

AngularJS Interview Questions:
  1. What is AngularJS?
  2. Explain Directives in AngularJS?
  3. What are expressions in AngularJS?
  4. Explain currency filter in AngularJS?
  5. What is $scope in AngularJS?
  6. What is “$rootScope” in AngularJS?
  7. What is $rootscope and how do we use it?
  8. What is SPA (Single page application) in AngularJS?
  9. How to implement routing in AngularJS?
  10. How many types of data binding in AngularJS?
  11. What is a Factory method in AngularJS?
  12. How are validations implemented in AngularJS?
  13. Explain what is Dependency Injection in AngularJS?
  14. Explain Convert Text To Uppercase Using AngularJS.
  15. Explain ng-repeat directive.
  16. What is controller in AngularJS?
  17. What are the filters in AngularJS?
  18. Explain Module And Controller In AngularJS.
  19. What are the services in AngularJS?
  20. Explain double click event in AngularJS?
  21. Explain ng-include, Click, and Repeat directive in AngularJS.
  22. Explain ng-disabled Directive in AngularJS
  23. Explain ng-app directive.
  24. Why are we using AngularJS and what are the advantages of AngularJS?
  25. What is Representational State Transfer(REST) in AngularJS.
  26. Explain ng-Switch Directive in AngularJS.
  27. Why we use $http service or ajax request in AngualrJS?
  28. Why to use AngularJS Global Object services?
  29. When and Why to use and create Services?
  30. Explain Provider Method in AngularJS.
  31. What is event handling in AngularJS?
  32. What are the top reasons why developers choose AngularJS?
  33. Explain $routeProvider in AngularJS?
  34. What are the attributes can be used during creation of a new AngularJS Directives?
  35. What are the different types of Directives in AngularJS?
  36. What are compile & link options in Custom Directives?
  37. Explain what is injector in AngularJS?
  38. Mention what are the characteristics of “Scope”?
  39. Give the differences between AngularJS and Backbone and Knockout?
  40. What is the difference between AngularJS and jQuery?
  41. What are the custom directives in AngularJS?
  42. What is AngularJS BootStrap Process?
  43. What is Constants in AngularJS?
  44. Explain ngClick And ngDblclick Directives In AngularJS?
  45. What is One-Way Data Binding in AngularJS?
  46. What is One-Way Data Binding in AngularJS?
  47. Explain ng-hide Directive in AngularJS?
  48. What are animating elements in AngularJS?
  49. What is ngClass directive in AngularJS?
  50. Why is scopeless controller used in AngularJS?
  51. Explain the concept of digest cycle, watchers and dirty checking?
  52. What can be the performance implications of watchers and digest cycle ?
  53. How can we measureno: of watchers & time spent on digest cycle?
  54. How can we decrease digest cycle time ?
  55. Can we force the digest cycle to run manually?
  56. Do I need Jquery for Angular?
  57. How is the data binding in Angular ?
  58. Explain compile and link phase?
  59. How do we make HTTP get and post calls in Angular?
  60. How do we pass data using HTTP POST in Angular ?
  61. What is dependency injection and how does it work in Angular?
  62. How does DI benefit in Angular?
  63. What are services in Angular?
  64. Are Service object instances global or local?
  65. What is the difference between Factory and Service?
  66. How are validations implemented in Angular?
  67. How to check error validation for a specific field?
  68. What does SPA (Single page application) mean?
  69. How can we implement SPA with Angular?
  70. How to implement routing in Angular?
  71. How to implement SPA using angular-UI route?
  72. Can we load HTML content rather than a full page ?
  73. How can we create controllers and pass parameters in Angular UI route?
  74. How to implement nested views using Angular UI route?
  75. How can we create a custom directive in Angular?
  76. What kind of naming conventions is used for custom directives?
  77. What are the different custom directive types in AngularJS?
  78. What if I want custom directives to be applied on element as well as attributes ?
  79. Can I set an Angular directive template to a HTML web page?
  80. Explain $q service, deferred and promises?

No comments:

Post a Comment

Jenkins Startup and Configuration

Steps to setup jenkins on ubuntu:- -After installation. check the jenkins services running on not on the server. sudo service jenk...