I want to use embeded tweets inside an ng-view partial but for some reason it not working. if I put it outside of the partial (directly in the index.html) it works. Does anyone has an idea how this can be fixed?
我想在ng-view部分内部使用嵌入式推文但由于某种原因它无法正常工作。如果我把它放在partial之外(直接在index.html中)就可以了。有谁知道如何解决这个问题?
2 个解决方案
#1
5
The problem is order in which tweeter script and your main.html is loaded: when mail.html is loaded before widget.js, tweeter's script is not able to find your backquote
element and render it nice way.
问题是加载了tweeter脚本和你的main.html的顺序:当在widget.js之前加载mail.html时,tweeter的脚本无法找到你的反引号元素并以很好的方式呈现它。
You can put <script ...>
into main.html, but in this case keep in mind, that Angular's jqLite does not support <script>
tags in partials, loaded via XHR. So you need to include real jQuery before angular.
您可以将
Here is a Plunker: http://plnkr.co/edit/rQUThnZNAyJQGFIwflGk?p=preview
这是一个Plunker:http://plnkr.co/edit/rQUThnZNAyJQGFIwflGk?p = preview
#2
4
It seams that we need to call again the twitter js - this isn't related to Angularjs in specific. Because Angular js partial view are not rendered immediately the problem happens. The solution is to call the js file again after the partial was loaded:
它接缝我们需要再次调用twitter js - 这与Angularjs无关。因为Angular js局部视图不会立即呈现,所以会发生问题。解决方案是在加载部分后再次调用js文件:
$timeout(function() {
$.ajax({ url: 'http://platform.twitter.com/widgets.js', dataType: 'script', cache:true});
}, 1000);
see: Re-render Tweet button via JS
请参阅:通过JS重新呈现推文按钮
#1
5
The problem is order in which tweeter script and your main.html is loaded: when mail.html is loaded before widget.js, tweeter's script is not able to find your backquote
element and render it nice way.
问题是加载了tweeter脚本和你的main.html的顺序:当在widget.js之前加载mail.html时,tweeter的脚本无法找到你的反引号元素并以很好的方式呈现它。
You can put <script ...>
into main.html, but in this case keep in mind, that Angular's jqLite does not support <script>
tags in partials, loaded via XHR. So you need to include real jQuery before angular.
您可以将
Here is a Plunker: http://plnkr.co/edit/rQUThnZNAyJQGFIwflGk?p=preview
这是一个Plunker:http://plnkr.co/edit/rQUThnZNAyJQGFIwflGk?p = preview
#2
4
It seams that we need to call again the twitter js - this isn't related to Angularjs in specific. Because Angular js partial view are not rendered immediately the problem happens. The solution is to call the js file again after the partial was loaded:
它接缝我们需要再次调用twitter js - 这与Angularjs无关。因为Angular js局部视图不会立即呈现,所以会发生问题。解决方案是在加载部分后再次调用js文件:
$timeout(function() {
$.ajax({ url: 'http://platform.twitter.com/widgets.js', dataType: 'script', cache:true});
}, 1000);
see: Re-render Tweet button via JS
请参阅:通过JS重新呈现推文按钮