ドットインストールにて「AngularJSで作るYouTube検索」をやってみているのですが、#6での記述が動作しないのです。ご教授お願いいたします。
エラー内容は"$http is not defined"とのことでして、
myscrip.js の以下の箇所でエラーになります。
$http.jsonp(url).success(function(data){
index.html
<!DOCTYPE html> <html lang="ja" ng-app="formExample"> <head> <meta charset="UTF-8"> <title>AnugluarJS YOUTUBE search</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script> <script src="myscript.js"></script> </head> <body> <h1>YOUTUBE SEARCH</h1> <div ng-controller="ExampleController"> <form ng-submit="doSearch()" name="myForm"> <input type="text" ng-model="query" required> <input type="submit" value="search" ng-disabled="myForm.$invalid"> </form> <h2>Results</h2> <ul ng-show="result.length" sytle="list-style:nome; padding:0"> <li ng-repeat="result in results"> <img ng-src="{{result.media$group.media$thumnail[0].url}}"> {{result.title.$t}} </li> </ul> <p ng-hide="result.length" >上から検索してください。</p> </div> </div> </body> </html>
myscript.js
angular.module('formExample', []) .controller('ExampleController', ['$scope', function($scope) { $scope.doSearch = function(){ var url = 'https://gdata.youtube.com/feeds/api/videos?'; +[ 'q=' +encodeURIComponent($scope.query), 'alt=json', 'max-results=10', 'v=2', 'callback=JSON_CALLBACK' ].join('&'); $http.jsonp(url).success(function(data){ //console.dir(data); $scope.results = data.feed.entry; }); } }]);
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。