These are chat archives for AngularClass/angular2-webpack-starter

11th
Jan 2018
texirv0203
@texirv0203
Jan 11 2018 22:19

hi,

  • right now I am passing hard coded value for my name.
  • I am trying to pass the dynamic username for my name key inside my scriprt tag from sportsService.
  • its working fine in my ts file.
  • but its not working fine in my html file.
  • I am getting an error. ---> Uncaught TypeError: Cannot read property 'marksSession' of undefined
  • can you guys tell me how to pass inside script tag of .html.
  • providing my code below

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];
        }
}