The article presents another set of 10 interview questions for you to try your understanding of AngularJS fundamentals. You may find some of them as tricky ones. Questions below primarily focus on angular application initialization process. Do note that I shall be coming up with multiple such set of questions in the near future as I swim deeper into Angular Sea. 🙂 Please feel free to suggest/comment if you disagree with any of the answers below.
- Can the angular application be initialized on only HTML element or ANY element?
Ans: ANY element
- Can an HTML page have multiple “ng-app” directive for bootstrapping multiple AngularJS application?
- With more than one ng-app in an HTML document (an HTML page), are they automatically initialized? Describe the angularJS application initialization process with multiple ng-app in an HTML document/page.
Ans: Only one AngularJS application can be auto-bootstrapped. The first ‘ng-app’ found in the document will be used to define the root element to auto-bootstrap as an application. To run multiple applications in an HTML document, one must manually bootstrap them using angular bootstrap service.
- Describe the steps involved in bootstrapping an angular application?
Ans: Following steps are involved in bootstrapping the angular application:
- Determine the element consisting of ng prefixes with “app”
- Check whethar an angular app already exists on the element
- Compile & link with the help of dependencies such as rootScope injected (used for linking).
- Can angular applications (ng-app) be nested within each other?
- What are various possible prefixes such as “ng-” using which Angular directives (for example, ng-app) can be defined?
Ans: “ng-“, “data-ng-“, “ng:”, “x-ng-“
- What are various possible ways in which angular application can be initialized?
Ans: On an element, one could either put simply the attribute such as (ng-app, data-ng-app, ng:app, x-ng-app) or put the named attribute such as (ng-app=”demoApp”).
- What angular function is used to manually start up an angular application?
- Can multiple angular applications be bootstrapped using same element?
Ans: No. An error is thrown such as “App Already Bootstrapped with this Element”
- At framework level, how does Angular retrieve the matching elements for processing?
Ans: Makes use of jqLite(element) function. If jQuery is used, jQuery(element) is used by way of assigning jQuery to jqLite variable.>
Do watch out this space for more AngularJS interview questions.
He has also authored the book, Building Web Apps with Spring 5 and Angular.
Latest posts by Ajitesh Kumar (see all)
- ML Models Confusion Matrix Explained with Examples - March 30, 2019
- Machine Learning Cheat sheet (Stanford) - March 23, 2019
- Machine Learning Models used in Facebook - March 3, 2019