Twitter widget only shows on the first page load

widgetsjs
angular

#1

I use Angular 2+ to embed Twitter widget into my app, however the widget only shows on the first page load. In general, I copy exactly the code from Twitter widget docs (https://dev.twitter.com/web/javascript/loading) and wrap into my function ngAfterViewInit. After routing away and comeback the page, Twitter widget disappears. Anyone has some suggestions?


#2

Hi there

It is hard to tell what’s wrong without an example but my guess would be that the markup that is created by Twitter widgets is being replaced during your app’s lifecycle. You should be able to (re)create widget using factory functions after the view is shown.


#3

Hi, thank you for your reply. I figured it out myself by wrapping the widget JS function and twttr.widgets.load() into setTimeOut function (https://stackoverflow.com/questions/47176195/embedded-twitter-widget-on-angular-2-app-only-shows-up-on-the-first-page-load). Hope it helps someone else.


#4

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.