Twitter widget only shows on the first page load



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 ( and wrap into my function ngAfterViewInit. After routing away and comeback the page, Twitter widget disappears. Anyone has some suggestions?


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.


Hi, thank you for your reply. I figured it out myself by wrapping the widget JS function and twttr.widgets.load() into setTimeOut function ( Hope it helps someone else.


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