Multiple Choice Questions - Angular2 Directives

Multiple Choice Questions - Angular2 Directives


1. In Angular 2 . . . . . . . . directive allows us to iterate through a collection.

A) NgRepeat
B) NgWhile
C) NgIf
D) NgFor

2. Both the following examples involving the directives are identical:

A) True
B) False

3. The shadow DOM allows to encapsulate the styles of web components without allowing them to leak outside the component’s scope. If we want Angular’s renderer to use the shadow DOM, we can use . . . . . . .

A) ViewEncapsulation.None
B) ViewEncapsulation.Native
C) ViewEncapsulation.Emulated
D) ViewEncapsulation.Natural

4. Which of the below syntax will clone and inject pieces of templated HTML snippets in the markup, removing it from the DOM when the condition evaluates to false.

A) *ngIf="conditional"
B) [hidden]="conditional"
C) ngIf*="conditional"
D) None of above

5. The three types of directives in Angular 2 are . . . . . . . . . . .

A) advanced directives
B) attribute directives
C) structural directives
D) components

6. We can use the NgFor and NgIf directives using the . . . . . . . symbol to indicate we're dealing with a directive that creates a template.

A) hash (#)
B) escape (/)
C) asterisk (*)
D) percent (%)

7. A special mention is required about the children element marked with the . . . . . . . . . . . directive attribute. This attribute qualifies the template that will be displayed when no other value defined by its ngSwitchWhen siblings matches the parent conditional expression.

A) ngDefault
B) ngTemplateDefault
C) ngDefaultSwitch
D) ngSwitchDefault

8. Since Angular 2 defines a set of built-in directives, the . . . . . . . . method passes them in a similar way in order to make them available in the entire application in order to prevent us from code duplications.

A) startup
B) bootstrap
C) constructor
D) initialization

9. Structural directives change the DOM layout by adding and removing DOM elements and the . . . . . . . . directives change the appearance or behavior of an element.

A) attribute
B) advanced
C) component
D) same

10. . . . . . . . . . refers to values that parameterize the directive’s behaviour and/or view. On the other hand, . . . . . . . . refers to events that the directive fires when something special happens.

A) Inputs, output
B) Output, inputs

Answers