0

I'd like to embed this code into my angular 7 application.

<link rel="stylesheet" type="text/css" href="https://cdn2.hubspot.net/hubfs/1716276/embeddable_assessments/disc/disc_assessment_v1.1.0.css" /> 
<script src="https://cdn2.hubspot.net/hubfs/1716276/embeddable_assessments/disc/disc_assessment_v1.1.0.js"></script>
<div id="disc_assessment_root" data-api-token="token-here"></div>
<script>
    window.crystalKnowsDISCResponse = function (response) {
        console.log('Here is the personality JSON response:', response)
    }
</script>

So the link and the script should stay in index.html, but i must use <div id="disc_assessment_root" data-api-token="token-here"></div> in my custom component, and

window.crystalKnowsDISCResponse = function (response) {
   console.log('Here is the personality JSON response:', response)
}

to get the results that the API returns.

leonheess
  • 16,068
  • 14
  • 77
  • 112
  • so what had you tried so far? – qiAlex Jan 15 '20 at 15:32
  • I downloaded the script and saved it as a local js file, imported it in angular.json and tried to declare a variable in the ts file of the component, but nothing happened. And tried something like this as well: https://stackoverflow.com/questions/56098810/angular-7-how-to-include-inline-js-script-into-component – Kristijan Vidojkovic Jan 15 '20 at 15:38
  • If someone else has this same problem, just follow these steps: https://stackoverflow.com/questions/34489916/how-to-load-external-scripts-dynamically-in-angular – Kristijan Vidojkovic Jan 20 '20 at 08:40

0 Answers0