In Angular2 I only want to add the addthis plugin to a specific route e.g. my /blog url but when I add a the script library it doesn't work.
It only seems to work on the index.html and not on a specific view like blog.html
In Angular2 I only want to add the addthis plugin to a specific route e.g. my /blog url but when I add a the script library it doesn't work.
It only seems to work on the index.html and not on a specific view like blog.html
Copyright © 2021 Jogjafile Inc.
Here you go: I implemented it for my use case following ng-addthis but adding a few extra checks for Angular SSR.
Then inject the service in your providers section of the main module and use it in ngAfterViewInit hook, like below:
You can also use isPlatformBrowser method for checking platform before calling initAddThis method if you are using Angular Universal.