Skip to content

Instantly share code, notes, and snippets.

@alexandrecruz
Created November 9, 2017 14:43
Show Gist options
  • Save alexandrecruz/82dc9a229665b3c6a97387bb9f8c7325 to your computer and use it in GitHub Desktop.
Save alexandrecruz/82dc9a229665b3c6a97387bb9f8c7325 to your computer and use it in GitHub Desktop.
Try to load Youtube iframe
'use strict';
// Youtube avilability detector
// ---
// Cases: $scope.youtubeAvilable
// null - Not completed the request yet
// true - Youtube API and iframe loaded
// false - Youtube API and iframe could not be laoded
$scope.youtubeAvilable = null;
$.get('https://www.youtube.com/iframe_api')
.then(function(){
// now we can set an indicator that youtube is loadable
$scope.youtubeAvilable = true;
})
.fail(function(){
// something went wrong..
$scope.youtubeAvilable = false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment