Thursday, 19 January 2017

ANGULARJS INTERVIEW QUESTIONS - Set 2

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

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

No comments:

Post a Comment