My subscribe button displays the text "Subscribe" when the page loads, but upon reloading the page, the text disappears. The button text is controlled by TypeScript code, and strangely, when I navigate to another route, the text magically reappears.
HTML
<button type="button" (click)="subscribe()" name="subscribe" id="subscribe">
<span *ngIf="!subscribeFormProcessing">Subscribe</span>
<span *ngIf="subscribeFormProcessing"><img [src]="btnLoaderUrl"></span>
</button>
Typescript
export class FooterWidgetComponent implements OnInit, OnDestroy {
subscribeEmailAddress: string;
subscribeEmailSubscriber: any;
btnLoaderUrl: string;
subscribeFormProcessing = false;
subscribeMsg: string;
constructor(private appSettingsService: AppSettingsService, private httpRequestService: HttpRequestService) {
}
ngOnInit() {
this.subscribeEmailAddress = '';
this.subscribeMsg = '';
this.btnLoaderUrl = this.appSettingsService.getImagesBaseUrl() + 'app/btn-loader.gif';
this.subscribeEmailSubscriber = this.httpRequestService.requestCompleted.subscribe(data => {
this.subscribeFormProcessing = false;
if (data['status'] === "success") {
this.subscribeMsg = data['message'];
} else {
this.subscribeMsg = data['message'];
}
this.clearSubscribeMessage()
});
}
clearSubscribeMessage() {
setTimeout(() => {
this.subscribeMsg = '';
}, 5000);
}
subscribe() {
this.subscribeFormProcessing = true;
this.httpRequestService.setUrl('subscribe');
this.httpRequestService.sendPost({email: this.subscribeEmailAddress});
}
ngOnDestroy() {
this.subscribeEmailSubscriber.unsubscribe();
}
}
On Page Reload
https://i.sstatic.net/E7KNM.png
After navigating to any route
https://i.sstatic.net/Ly0OP.png
Root Cause I am using Addthis widget for sharing post and blog. Initializing the addthis on blog page load seems to be causing this particular issue.
initAddThisToolbar() {
addthis.layers.refresh();
}
HTML
<div class="addthis_inline_share_toolbox"></div>
Is there a different method to refresh the addthis widget?