I'm facing an issue in my schedule.component.html where I am trying to create a button and link its click event with a function defined in the associated schedule.component.ts file.
The button is coded like this:
<button type="submit"
(click)="onSubmitExporter2()">
Propose passes
</button>
Although the button appears correctly, clicking it doesn't trigger any action and the console displays an error message stating: TypeError: onSubmitExporter2() is not a function.
This is the method I have created:
public onSubmitExporter2(): void {
console.log('onSubmitExporter2() called');
const exporter: Exporter = {
loading: false,
success: false,
successMessage: '',
error: false,
errorMessage: '',
info: '',
exportTime: '',
exportStatus: '',
name: 'Download Proba-3 Pass Plan',
endpoint: '',
description: '',
returnFile: false,
parameters: []
};
const exporterPath = 'adapter/gsms/exporter/proba3_pass_plan_export'; // Specify the exporter path
const queryParams = new Map<string, string>(); // Optional: Add query parameters if needed
queryParams.set('download', 'true');
this.opsWebDataService.exporter(exporterPath, queryParams).subscribe(
(r) => {
if (!exporter.returnFile) {
exporter.info = r.info;
exporter.exportTime = r.last_export;
exporter.exportStatus = r.status;
} else {
const disposition = r.headers.get('content-disposition');
let filename = disposition.split(';')[1].trim().split('=')[1];
filename = filename.replace(/"/g, '');
const file = new File([r.body], filename,
{ type: r.headers.get('content-type') });
saveAs(file);
}
this.onSuccessExport(exporter);
},
(error) => {
// Handle errors
console.error(error);
}
);
}
This code snippet resides within the export class DataTransfer.
If anyone has any solutions, please share them. Thank you!