的index.html
<script>
(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',intercomSettings);}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/APP_ID';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})()
</script>
<script>
let players=this.sportsService.marksSession();
console.log("players--->" + players);
if(players) {
this.userId = players.user_players.SSO[0];
}
Intercom('trackEvent', 'share-link');
window.intercomSettings = {
app_id: 'APP_ID',
name: "Jane Doe", // Full name
email: "customer@example.com", // Email address
created_at: 1312182000 // Signup date as a Unix timestamp
};
</script>
sports.ts
import { sportsService } from '../../services/sports.service';
constructor(public sportsService : sportsService){
}
ngOnInit() {
let that =this;
let players=this.sportsService.marksSession();
if(players) {
this.userId = players.user_players.SSO[0];
}
}
答案 0 :(得分:0)
如果您在HTML页面上导入TypeScript文件,那么应该处理您正在获取的TypeError。我相信在执行此操作之前,您需要将TypeScript编译为JavaScript。
查看W3Schools,了解有关如何在HTML中使用该标记的一些信息: https://www.w3schools.com/tags/att_script_src.asp