@viewchild elementref 1

@viewchild elementref

@ViewChild('ID', {static: true}) NAME: ElementRef | undefined;

Here is what the above code is Doing:
1. We are importing the ElementRef class from the @angular/core package.
2. We are using the @ViewChild decorator to inject the element into the component class.
3. We are using the ElementRef class to access the element.

The @ViewChild decorator takes the following two parameters:
1. The name of the element to inject.
2. An object with a property called static.

The static property is set to true if the element is available when Angular creates the component.

The static property is set to false if the element is available after Angular creates the component.

The static property is optional. If you omit it, Angular assumes the element is available when Angular creates the component.

The @ViewChild decorator returns an instance of the ElementRef class.

The ElementRef class has a property called nativeElement.

The nativeElement property returns the element as an HTML element.

The nativeElement property is read-only.

The nativeElement property is of type any.

The nativeElement property is of type HTMLElement.

The nativeElement property is of type Element.

The nativeElement property is of type HTMLInputElement.

The nativeElement property is of type HTMLSelectElement.

The nativeElement property is of type HTMLTextAreaElement.

The nativeElement property is of type HTMLButtonElement.

The nativeElement property is of type HTMLAnchorElement.

The nativeElement property is of type HTMLImageElement.

The nativeElement property is of type HTMLDivElement.

The nativeElement property is of type HTMLSpanElement.

The nativeElement property is of type HTMLParagraphElement.

The nativeElement property is of type HTMLTableElement.

The nativeElement property is of type HTMLTableRowElement.

The nativeElement property is of type HTMLTableCellElement.

The nativeElement property is of type HTMLTableSectionElement.

The nativeElement property is of type HTMLTableColElement.

The nativeElement property is of type HTMLTableCaptionElement.

The nativeElement property is of type HTMLTableHeaderCellElement.

The nativeElement property is of type HTMLTableDataCellElement.

The nativeElement property is of type HTMLTableSectionElement.

The nativeElement property is of type HTMLTableRowElement.

The nativeElement property is of type HTMLTableCellElement.

The nativeElement property is of type HTMLTableColElement.

The nativeElement property is of type HTMLTableCaptionElement.

The nativeElement property is of type HTMLTableHeaderCellElement.

The nativeElement property is of type HTMLTableDataCellElement.

The nativeElement property is of type HTMLTableSectionElement.

The nativeElement property is of type HTMLTableRowElement.

The nativeElement property is of type HTMLTableCellElement.

The nativeElement property is of type HTMLTableColElement.

The nativeElement property is of type HTMLTableCaptionElement.

The nativeElement property is of type HTMLTableHeaderCellElement.

The nativeElement property is of type HTMLTableDataCellElement.

The nativeElement property is of type HTMLTableSectionElement.

The nativeElement property is of type HTMLTableRowElement.

The nativeElement property is of type HTMLTableCellElement.

The nativeElement property is of type HTMLTableColElement.

The nativeElement property is of type HTMLTableCaptionElement.

The nativeElement property is of type HTMLTableHeaderCellElement.

The nativeElement property is of type HTMLTableDataCellElement.

The nativeElement property is of type HTMLTableSectionElement.

The

Similar Posts