我想在我的 Angular 2 应用程序中使用对讲机。
对讲SPA说明是here
我已将脚本 block 放在 index.html 页面的头部,我的下一个想法是将以下内容放在我的应用程序组件中
ngOnInit()
{
window.Intercom("boot", {
app_id: "abcd",
name: "Jane Doe", // Full name
email: "customer@example.com", // Email address
created_at: 1312182000 // Signup date as a Unix timestamp
});
但是,它不会编译说 [ts]
Property 'Intercom' does not exist on type 'Window'.
如何使用 Angular2 和 webpack 让它工作并进一步进行?
最佳答案
我找到了将对讲机与 angular 2 集成的答案
更新 angular 2 的对讲指令 而不是这个:
window.Intercom("boot", {
app_id: "abcd",
name: "Jane Doe",
email: "customer@example.com",
created_at: 1312182000
});
使用它使其工作:
(<any>window).Intercom("boot", {
app_id: "abcd",
name: "Jane Doe",
email: "customer@example.com",
created_at: 1312182000
});
关于Angular 2 和 Intercom.io,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38342252/