So got a problem, actually, I have four problems, but they are all the same issue (or so I think). Decided to use google, twitter, whatsapp and facebook API to do share buttons. Both comes nicely packaged and available from facebook and google, makes a simple but nice button on the webpage, and does the trick.
Problem is that these scripts are not written for angular, and reading up on the issue, I think what is happening is that the scripts loads and wait for the DOM, then tries to find its "triggers", i.e. divs and buttons its suppose to replace. In my case the following:
<a href="whatsapp://send" data-text="Unbrand: the webpage you need" data-href="http://unbrand.me/share/whatapp" class="wa_btn wa_btn_s" style="display:none; margin-bottom: 8px;">Share</a>
<a href="https://twitter.com/share" style="margin-bottom: 8px;" class="twitter-share-button" data-url="http://unbrand.me/share/twitter" data-text="UnBrand - Tailored clothes just for you" data-mobile-iframe="true" data-via="unbrand_me" data-related="unbrand_me" data-hashtags="unbrand_me">Tweet</a>
<div class="fb-share-button" style="margin-bottom: 8px;" data-href="http://unbrand.me/share/facebook" data-layout="button_count" data-mobile-iframe="true"></div>
<div class="g-plus" style="margin-bottom: 8px;" data-action="share" data-annotation="bubble" data-href="http://unbrand.me/share/google"></div>
</md-fab-actions>
Problem is (or I think it is) that when they scan the DOM, angular haven't loaded this DOM, or at least not four out of five times, so the divs are never found, the script think its done, and angular makes a normal link or div. I could be wrong, but reading this (and other issues) this seems to be the way.Google Signin button in AngularJS sometimes does not show up
There was a solution on this one thread that was really interesting, the option of creating a watcher to watch for a change to the object, so added the following to the controller for that part of the page:
$scope.$watch('gapi', function(newValue,oldVale){
if(newValue !== oldVale){
if(gapi){
console.log("GAPI loaded")
gapi.share.render('shareButton',
{
'onsuccess': $scope.onSuccess,
'onfailure': $scope.onFailure,
'scope':'https://www.googleapis.com/auth/plus.login'
}
);
}
}
});
I do not know if gapi.share.render is a function of gapi, but for now my issue is that the watcher never renders. My idea was that I would identify a key function in each of the java scripts and get the watcher to look for it. But I can't get the above function to work.
Am I missing something obvious?
Oh, the API I am using
<script src="https://apis.google.com/js/platform.js" async defer></script>