0

In my angular component, I have to access a variable defined in window scope. For that, I have defined like below.

if (this.window.nativeWindow.KAMPYLE_ONSITE_SDK) {
  console.log(' sureveyDisplayed :- ' + this.window.nativeWindow.KAMPYLE_ONSITE_SDK.isSurveyDisplayed());
  console.log(' updatePageView :- ' + this.window.nativeWindow.KAMPYLE_ONSITE_SDK.updatePageView());
}

After adding this, typescript throws compilation error

error TS2339: Property 'KAMPYLE_ONSITE_SDK' does not exist on type 'Window'.

I understand that typescript cannot find this variable defined anywhere but can anyone tell me how to embed a variable defined in window scope into a angular component?

Thanks, Suresh

Suresh
  • 41
  • 3
  • 1
    possible duplicated of https://stackoverflow.com/questions/12709074/how-do-you-explicitly-set-a-new-property-on-window-in-typescript – AsukaSong Feb 23 '21 at 03:04
  • Thanks for pointing out. In our case, this variable is loaded by a third-party javascript file. Until this file is loaded, we won't have this variable available. – Suresh Feb 24 '21 at 14:46

0 Answers0