May 17, 2020 4:06 PM
Hi, I am trying to add Hubspot to Angular 8. I added the script in index.html and its works fine but I want to add Hubspot in one component only so how can I add HubSpot in particular components HTML or TS file? Please help me in this. Thank you
May 25, 2020 5:21 AM
In order to assist here, could you provide more context of what you're looking to do when you mention you're looking to 'add HubSpot in particular components HTML or TS file'.
If you can elaborate on your goals, we may be able to better assist.
Aug 8, 2021 6:07 PM
So before explaining what he was asking I would need to explain the Angular structure first.
In Angular, we have a "base" HTML file named "index.html" where you can apply the js code for global use. As he put the code there, users will be able to access Hubspot on all the pages he has.
And component is a minor part of Angular that only loads when needed. It contains a HTML file, a ts file and sometimes a css file. That component does not support js.
So what he was asking is if there is a way he can allow Hubspot only loads when certain component loads, and remove it when the component is removed from the page. In my mind the easiest way to do so is to install Hubspot as a NPM package if possible. But I cannot find such a package at the moment.
I am facing the same issue for now. It would be helpful if you can reply this.