HalitTalha / ng-material-extensions

Extended features for @angular/material components
Apache License 2.0
101 stars 52 forks source link

Prod fails but dev works fine in Angular 8 #15

Closed ojnc closed 5 years ago

ojnc commented 5 years ago

I am suing Angular 8
ng serve <button mat-raised-button color="warn" (click)="exporter.exportTable('xlsx', {fileName:'seekureg', sheet: 'sheetkureg', Props: {Author: 'RGrover'}})" >Excel

Works fine in Dev mode

When I do ng build --prod --base-href /seekureg/

ERROR in src/app/demo/demo.component.html(6,6): : Argument of type '"xlsx"' is not assignable to parameter of type 'ExportType'

Please help suggest a workaround I borrowed code from your https://stackblitz.com/edit/mte-demo

Regards Jayanta @ Kolkata

HalitTalha commented 5 years ago

Thank you for reporting this. Actually I did not face this when testing with Angular 8. Could you share your exact Angular CLI version?

By the way you can get rid of this type error by passing the exact Enum of ExportType as below

in your .ts file:

// define the export type to a variable in order to use it in html template.
import { ExportType } from 'mat-table-exporter';

export class SomeComponent {
...
exportType = ExportType.XLSX;

in your html template:

<button mat-raised-button color="warn"
(click)="exporter.exportTable(exportType, {fileName:'seekureg', sheet: 'sheetkureg', Props: {Author: 'RGrover'}})" >Excel
ojnc commented 5 years ago

Thanks a lot I had to do 1 more thing based on your documentation and it is working fine import { ExportType,ExcelOptions } from 'mat-table-exporter';

options:ExcelOptions = {fileName:'seekureg', sheet: 'sheetkureg', Props: {Author: 'RGrover'}}; besides exportType = ExportType.XLSX;

The button code now is <button mat-raised-button color="warn" (click)="exporter.exportTable(exportType,options)" >Excel

Thanks again! Jayanta @ Kolkata

My ng version

Angular CLI: 8.1.3 Node: 10.15.3 OS: win32 x64 Angular: 8.1.3 ... cli, common, compiler, compiler-cli, core, forms ... language-service, platform-browser, platform-browser-dynamic ... router

Package Version

@angular-devkit/architect 0.801.3 @angular-devkit/build-angular 0.801.3 @angular-devkit/build-optimizer 0.801.3 @angular-devkit/build-webpack 0.801.3 @angular-devkit/core 8.1.3 @angular-devkit/schematics 8.1.3 @angular/animations 8.2.5 @angular/cdk 8.1.4 @angular/flex-layout 8.0.0-beta.27 @angular/material 8.1.4 @ngtools/webpack 8.1.3 @schematics/angular 8.1.3 @schematics/update 0.801.3 rxjs 6.4.0 typescript 3.4.5 webpack 4.35.2