AngularJS Interview Questions: Set 2
This article presents another set of 10 interview questions for you to try your understanding of AngularJS fundamentals.
Join the DZone community and get the full member experience.Join For Free
[editor's note: be sure to check out set 1 , too]
this article presents another set of 10 interview questions for you to try your understanding of angularjs fundamentals . you may find some of them to be tricky ones. questions below primarily focus on the 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?
ans : yes
- 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?
a ns : no
- 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?
ans : angular.bootstrap
- 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 .
Published at DZone with permission of Ajitesh Kumar, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.