【问题标题】:Igx Button to open a link and download a fileIgx 按钮打开链接并下载文件
【发布时间】:2022-06-27 20:51:46
【问题描述】:

点击 igx 按钮时是否可以通过链接下载文件(例如 Power point 演示文稿)?我找不到任何与我的问题相关的主题。

这是我的示例代码:

  <button igxButton="raised" (click)="downloadFile()" class="downloadBtn">
    Download File
  </button>

和功能:

downloadFile() {
   let exampleLink = "https://downloadexamplefile.com/fileid123"
  }

谢谢!

【问题讨论】:

    标签: angular ignite-ui ignite-ui-angular


    【解决方案1】:

    此功能并非特定于 igxButton。该按钮可能会触发下载操作,尽管实际操作是您需要处理的。

    一个例子是创建一个 Service 并指定 responseType 选项,该选项在 GET 请求时可以返回代表下载文件的 blob。然后就可以调用这个服务,订阅对应的observable,最终在igxButton click

    保存文件

    示例: https://www.thecodehubs.com/download-file-with-httpclient-in-angular/

    【讨论】:

    • 是的,谢谢,我修好了。我通过window.open(downloadURL.com")打开了带有文件下载的URL;
    猜你喜欢
    • 2021-11-22
    • 1970-01-01
    • 2015-08-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-25
    • 1970-01-01
    相关资源
    最近更新 更多