Angular 2 和 Intercom.io

标签 angular webpack intercom

我想在我的 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/

相关文章:

javascript - Angular 2 中的元素更新

javascript - 找不到名称 'BrowserWindow'

validation - Angular 2 中的条件必需验证器指令

javascript - Webpack Encore : cannot import local dependencies

intercom - 是否可以将 Intercom Messenger 放在左下角?

angular - 如何将组件导入 Angular 2 中的另一个根组件

javascript - webpack、react 和 babel : Uncaught TypeError: Super expression must either be null or a function, 未定义

javascript - Webpack 错误无法解析 JSX

gatsby - 使用Gatsby的Intercom插件集成Intercom

javascript - 使用Java for Intercom创建/更新销售线索?