【发布时间】:2020-02-16 05:14:33
【问题描述】:
在我的 .html 文件中,我有以下代码:- 这里出现了数据导入按钮......
<button mat-menu-item (click)="download()">
<mat-icon>cloud_download</mat-icon>
<span>Data Import</span>
</button>
在 component.ts 文件中:-
这里我定义了点击按钮后要调用的函数::
constructor(
private downloadService: DownloadService
)
download(){
this.downloadService.getDownload();
}
在 downloadservice.ts 文件中:-
这里已经创建了服务,它将在后端调用 api /Download。
export class DownloadService {
etext : String;
baseUrl: string = environment.apiUrl + '/Download';
constructor(private http: HttpClient) { }
getDownload() {
return this.http.get(this.baseUrl);
this.etext="The operation has been done";
}
}
当我点击数据导入按钮时..没有任何反应,也没有生成任何事件。
【问题讨论】:
标签: javascript angular typescript