What is the purpose of the ViewChild decorator in this component class?
@Component({
. . .
template: '<p #bio></p>'
})
export class UserDetailsComponent {
@ViewChild('bio') bio;
}
- 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. - It indicates that the
<p>
tag be rendered as a child of the parent view that uses this component. - It makes the
<p>
tag in the template support content projection. - 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.