New to Kendo UI for Angular? Start a free 30-day trial

Accessing a Component Instance in the ts Part of an Angular Component

Environment

ProductProgress® Kendo UI® for Angular

Description

I am using <kendo-pdf-export> in the template of a component. How can I access the PDFExportComponent from within the .ts part of the Angular component?

Solution

To achieve the desired scenario, use either of the following approaches:

Using the ViewChild Decorator

To query the component from the template, use the Angular @ViewChild decorator:

Example
View Source
Change Theme:

Using a Template Variable

To get a reference to the component and pass it as a function argument, use a template variable:

Example
View Source
Change Theme: