It took me one day to make it works so I think my experience may be useful from someone. And maybe some others will find improvement.
So I start angularJS two days a
So I was having the same problem. Putting this code in my factory worked
var initialize = function() {
if(gapi.client == undefined) {
setTimeout(function() {
initialize()
}, 1000);
} else {
gapi.client.setApiKey("");
gapi.client.load('youtube', 'v3').then(function() {
console.log("youtube is ready")
});
}
};
initialize()
Basically, the problem is trying to call gapi.client before it loaded. If you just check that it's loaded, and if it isn't then try again in a second (you can set the time for whatever you want, set it lower if you expect the user to need this relatively quickly after the page loads).
I was struggling with this for a while, and this is all that worked for me...Hope this helps!