首页 > 解决方案 > 我们如何在 html 代码中调用 typescript 函数(不在同一个文件中)

问题描述

我正在尝试为 Grafana 做一个插件,所以我以时钟面板(由 Grafana 提供)为例。

所以我的问题是我试图从 html 文件 options.html 中的文件 clock_ctrl.ts 调用 TypeScript 函数。

我尝试了很多方法:

  1. <form [ngFormModel]="companyForm" (submit)="namefunction()">
      <button type="submit">Save</button>
    </form>
    

但它不起作用

  1. <script src="../clock_ctrl.ts"></script>
    <body onload ="namefunction();">  </body>
        <button type="submit">Save</button>
    

但我得到了错误

获取http://localhost:3000/clock_ctrl.ts 404(未找到)

我找不到解决问题的方法。

标签: javascripthtmlangulartypescriptgrafana

解决方案


推荐阅读