问题
I'm having trouble with getting a youtube video title using AngularJS
Here's the code I have so far:
services.js
var myServices = angular.module('myServices', ['ngResource']);
myServices.factory('ytapi', ['$resource',
function($resource) {
return $resource('http://gdata.youtube.com/feeds/api/videos/gzDS-Kfd5XQ?alt=json-in-script&callback=JSON_CALLBACK&prettyprint=true&fields=title', {}, {
jsonp_query: {
method: 'JSONP'
}
});
}
]);
controllers.js
var myApp = angular.module('myApp', ['myServices']);
myApp.controller('MyController', ['$scope', 'ytapi',
function($scope, ytapi) {
$scope.feeds = ytapi.jsonp_query();
console.log()
}]);
What I don't know how can I parse the data so I could show the title of the video alone instead of the whole JSON.
来源:https://stackoverflow.com/questions/24019762/getting-a-youtube-video-title-using-angularjs