Integrating the Angular Report Viewer with Angular CLI
This tutorial demonstrates how to add the Angular Report Viewer component to a new Angular application. The app's settings are similar to the settings of the local Angular demo project installed by default under [TelerikReporting_InstallDir]\Examples\Angular\CLI
.
Prerequisites
The following list describes the prerequisites for this tutorial:
- Review the Angular Report Viewer Requirements.
- Angular CLI.
- A running application that hosts a Reporting REST service at address
/api/reports
. For more information, see Telerik Reporting REST Services. - Copy of the "Product Catalog.trdp" report file from
[TelerikReporting_InstallDir]\Report Designer\Examples
placed in the folder used by the UriReportSourceResolver in the Reporting REST service implementation. -
Entry with the default connection string used by Telerik Reporting sample reports in the
web.config
/appsettings.json
file of the project hosting the Reporting REST service.XML-based configuration file:
JSON-based configuration file:
Using Angular Report Viewer in Angular application
All paths and url links in the described steps must be adapted according to your project setup.
Steps:
- Create new Angular application using the Angular CLI tutorial.
-
Install jQuery by using the following command:
-
Add a reference to jQuery in the scripts array of the
angular-cli.json
(as of Angular 6 the file is renamed toangular.json
):If your
node_modules
folder is not in the same directory as theangular.json
file, adjust this path to that location. -
Install the Telerik Angular Report Viewer NPM package by running:
If you receive a 403 Forbidden Error, you need to register and login at npmjs.com before performing this step.
-
Once installed, import the TelerikReportingModule in your application root module:
-
Add the desired report viewer container style using a property of the AppComponent class:
-
Use the report viewer selector in the AppComponent template:
For all available report viewer options refer to Options.
-
Style the viewer using the desired Kendo UI theme (еither using Less-Based Themes or Sass-Based Themes): Add references to the Less-based CSS files in the
<head>
element of index.html:To get the Sass-based Kendo UI themes, you can use either the pre-build CSS files or the NPM packages (Getting the Sass-Based Themes).
If you use the styleUrls attribute to reference the CSS, it is required to set the view encapsulation to None:
-
Run the application: