APIs & Integrations

Ramya123
Member

Add Hubspot in only one component Angular

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

3 Replies 3
ZLiang
Participant

Add Hubspot in only one component Angular

Hey @Willson 

 

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.

0 Upvotes
PPrint
Member

Add Hubspot in only one component Angular

@Willson I also have the same query. Please reply

0 Upvotes
Willson
HubSpot Employee
HubSpot Employee

Add Hubspot in only one component Angular

Hey @Ramya123 

 

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. 

 

Thanks!

Product Manager @ HubSpot
0 Upvotes