Skip to content

Instantly share code, notes, and snippets.

@debugmodedotnet
Last active November 23, 2015 10:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save debugmodedotnet/d09d7d62baffdded1402 to your computer and use it in GitHub Desktop.
Save debugmodedotnet/d09d7d62baffdded1402 to your computer and use it in GitHub Desktop.
myApp.directive('angularYoutube', function ($sce) {
return {
restrict: 'E',
scope: { video: '=' },
replace: true,
template: '<div style="height:300px;"><iframe style="overflow:hidden;height:100%;width:100%" width="100%" height="100%" src="{{url}}" frameborder="1" allowfullscreen></iframe></div>',
link: function (scope) {
scope.$watch('video', function (newVal) {
if (newVal) {
scope.url = $sce.trustAsResourceUrl("http://www.youtube.com/embed/" + newVal);
}
});
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment