0/57

Angular

What is the purpose of the ViewChild decorator in this component class?

angularjs @Component({ ... template: '<p #bio></p>' }) export class UserDetailsComponent { @ViewChild('bio') bio; }

1.

It provides access from within the component class to the ElementRef object for the `<p>` tag that has the bio template reference variable in the component's template view.

2.

It indicates that the `<p>` tag be rendered as a child of the parent view that uses this component.

3.

It makes the `<p>` tag in the template support content projection.

4.

It makes the `<p>` tag visible in the final render. If the #bio was used in the template and the @ViewChild was not used in the class, then Angular would automatically hide the `<p>` tag that has #bio on it.

Q 1 / 57

Press C to Clear

Press R to Reset

Press N or Enter to Next or Check answer

Press 1,2,3, ... to toggle answers