JSFiddle - React, Tailwind, and code Playground
by sandro_paganotti
HTML
<div ng-app="sampleApp">
<input ng-model="queryString">
<sp-video query="queryString">
</div>
JavaScript
angular.module("sampleApp",[])
.directive("spVideo", function($http){
return {
restrict: 'E',
scope: {
query: '='
},
link: function(scope){
scope.$watch("query",function(valore){
if(!valore) return;
$http.get('http://gdata.youtube.com/feeds/api/videos/?alt=json&q=' + valore)
.success(function(data){
scope.videos = data.feed.entry;
});
});
},
template: '<ul><li ng-repeat="video in videos">{{video.title.$t}}</li></ul>'
};
});