如何在Javascript中读取TypeScript常量?

时间:2017-07-22 05:14:42

标签: javascript angular typescript

我有一个Angular 4应用程序,它也使用了一些遗留的HTML / JS页面。

如何读取TypeScript常量:

export class Constants {
    public static readonly MY_CONST = "test";
}

来自我的" Legacy" HTML / JS代码,假设我使用Angular AOT编译器(ng build -aot)构建所有内容,它们都包含我的TypeScript和遗留的HTML / JS:

<html>
 <head>
  <script type="text/javascript">
    var conf = Constants.MY_CONST;
    console.log(conf);
  </script>
 </head>
 <body>
 </body>
</html>

如何执行此操作Constants.MY_CONST?在这里,我希望conf是一个字符串,其中包含TypeScript常量中常量的内容。

0 个答案:

没有答案