Twitter list in angularjs application does not render after initial load

不问归期 提交于 2020-01-25 04:43:08

问题


I have a simple angularjs application with a pretty standard ng-view as follows:

    <div id="myContent">
        <div ng-view></div>
    </div>

My home page partial contains a twitter list:

<div class="container">
 <a class="twitter-timeline" width="1200" height='450' data-chrome="noheader nofooter noborders transparent"
data-tweet-limit="1" href="https://twitter.com/....."
data-widget-id="123.....">Tweets from
https://twitter.com/abc/def</a>
 <script> !function (d, s, id) {
 var js, fjs = d.getElementsByTagName(s)[0], p = /^http:/.test(d.location) ? 'http' : 'https';
 if (!d.getElementById(id)) {
                js = d.createElement(s);
                js.id = id;
                js.async=true;
                js.src = p + "://platform.twitter.com/widgets.js";
                fjs.parentNode.insertBefore(js, fjs);
            }
        }(document, "script", "twitter-wjs");</script>
    </div>

This works great on the first time the partial is accessed, the twitter list is rendered after a few seconds, but on subsequent returns to the partial the twitter list does not render unless I do a page refresh, and simply shows a link :Tweets from https://twitter.com/abc/def.

Is there a way that I could invoke a refresh of the twitter list in my controller? I could add it to a $timeout to invoke the widget once the page is rendered, but what function do I invoke to make the widget render?

Else do I need to query the twitter api directly (which I would like to avoid), and get the data directly ?


回答1:


There is an answer here: Why will my twitter widget not render if i change the view in angularjs? and here: https://twittercommunity.com/t/cannot-update-tweet-button-with-ajax/16989/2

Just to make it easier to see that this problem is solved (:



来源:https://stackoverflow.com/questions/22182554/twitter-list-in-angularjs-application-does-not-render-after-initial-load

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!