AngularJS Online Test Questions part 3

13. What are various possible ways in which angular application can be initialized?

a. On an element, one could either put simply the attribute such as (ng-app, data-ng-app, ng:app, x-ng-app)
b. Put the named attribute such as (ng-app=’demoApp’)
c. Both of the above
d. None of the above

Answer: c. Both of the above

Explanation: There are two ways to initialize angular application,

1. Automatic initialization
2. Manual initialization

All that is needed for automatic initialization is to define “ng-app” on an element. For example, ng-app=”HelloApp”

One could also initialize the angular app manually. This seems to be suited more for existing/legacy web pages where you would want to initialize angular app for a particular set of “views” or, initialize the app conditionally. For example, angular.bootstrap(document, ['HelloApp']);


14. Filter is applied to an expression using which character?

a. = (equal)
b. . (dot)
c. | (Pipe)
d. - (minus)

Answer: c. | (Pipe)

Explanation: Filters can be added in AngularJS to format data. These can be added to expressions by using the pipe character |, followed by a filter.
For example,
<p>Name {{ FirstName | uppercase }}</p> //The uppercase filter format strings to upper case


15. What angular function is used to manually start up an angular application?

a. angular.bootstrap
b. angular.element
c. angular.copy
d. None of the above

Answer: a. angular.bootstrap

Explanation: The angular.bootstrap is used to manually start up an angular application. Manual initialization is used in the case where we want more control over the initialization process.


16. Can multiple angular applications be bootstrapped using same element?

a. Yes
b. No

Answer: b. No

Explanation: An error is thrown such as ‘App Already Bootstrapped with this Element'.


17. At framework level, how does Angular retrieve the matching elements for processing?

a. Makes use of jqLite(element) function.
b. If jQuery is used, jQuery(element) is used by way of assigning jQuery to jqLite variable
c. Both of the above
d. None of the above

Answer: c. Both of the above

Explanation: The meanings of the words are: So, when you hum, you sing in a low voice, sometimes may be without words. Similarly, when you mumble, you say something quietly.


18. The legal restrict value "M" is used to invoke directive for which meathod?

a. Element name
b. Attribute
c. Class
d. Comment

Answer: d. Comment

Explanation: By using 'M', Comment will invoke the directive.