问题
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