我正在尝试将动态脚本插入index.html的头部,但脚本包含一个变量。见下文 - 该变量应插入由{{shopName}}指示的shopOprigin中,该appOprigin是通过app.component.ts中的ActivatedRoute获得的
<script>
ShopifyApp.init({
shopOrigin: 'https://{{shopName}}.myshopify.com'
});
</script>
答案 0 :(得分:0)
您不应该想要使用HTML中的environment
变量。您应该尝试将ShopifyApp库导入index.html
的头部然后调用该函数:
ShopifyApp.init({
shopOrigin: 'https://' + environment.shopName + '.myshopify.com'
});
可能是您的app.module.ts
或main.ts
(在您启动应用程序之前)。在这两个文件中,您都可以导入和使用environment
变量。