View Children in Angular
View Children in Angular
RajShekhar
Overview:
In Angular, components often need to interact with elements or
components within their template.
Angular provides several mechanisms to query and access
WHAT IS VIEW CHILDREN these elements. One such mechanism is @ViewChildren
IN ANGULAR? GIVE
SHORT
DETAILS AND EXAMPLE
Purpose:
@ViewChildren decorator is used to query for elements,
directives, or components from the view DOM
within an Angular component. It allows a component to
interact with multiple child elements or components.
Usage:
Syntax: 1.Import Statement:
Typescript You need to import ViewChildren from @angular/core to use it
2.Decorate Property:
•Selector: The CSS selector, directive, Decorate a property of your component with @ViewChildren
followed by the selector, directive, or component type you wantto query for.
or component type to query for.
Later, in ngAfterViewInit(),
you can access these elements
through the items property and perform
operations on them.
THANK YOU