import {Component, ElementRef, Input} from '@angular/core'; import {ActivatedRoute} from '@angular/router'; interface addthis { layers: refresh; init: Function; } interface refresh { refresh: Function; } declare var addthis: addthis; // @Component({ selector: 'addThis', template: `
` }) export class AddThisComponent { private sub:any; constructor(private route: ActivatedRoute) { } ngOnInit() { this.sub = this.route.queryParams.subscribe(data => { if (typeof document !== 'undefined' && typeof addthis !== 'undefined') { try{ addthis.init(); addthis.layers.refresh(); }catch (e) { console.log("AddThis may didn't load properly"); } } }); } }