Why will my twitter widget not render if i change the view in angularjs?

前端 未结 6 1658
日久生厌
日久生厌 2021-01-01 22:46

Hi and thanks for reading.

I have a angular app im making and ive stumbled on a problem. set up as so

index.html-



        
6条回答
  •  一生所求
    2021-01-01 23:20

    Basically it's what Loc Nguyen say.

    So every time you recreate it you must remove it first.

    var $ = function (id) { return document.getElementById(id); };
    function loadTwitter() {!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.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");}
    
    var twitter = $('twitter-wjs');
    twitter.remove();
    loadTwitter(); 
    

提交回复
热议问题