Getting a Youtube video title using AngularJS

限于喜欢 提交于 2019-12-22 09:28:34

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!