I'm new with angular2,I need to get my playlist videos from Youtube with angular 2 and Youtube API, but I don't know the best form to begin this task, anyone can help me?
-
1You should checkout [angular-cli](https://github.com/angular/angular-cli). [The official docs](https://angular.io) are also a good place to start. – Jack Clancy Apr 13 '17 at 02:08
2 Answers
You may refer with this related thread: Get all YouTube Videos in a Playlist using Angular JS. From the documentation, use the nextPageToken
attribute from the api response.Call the API one or more times to retrieve all items in the list. As long as the API response returns a nextPageToken, there are still more items to retrieve.
In your controller, define a local variable
nextPageToken
to retrieve the next page and call thegetPlaylistVideos
with thenextPageToken
attribute recursively until all the results are retrieved.
Be also noted that the function getPlaylistVideos
doesn't return anything, it updates the $scope.playlistVideos
variable with the fetched playlist items. Also the function getPlaylistVideos
uses the scope variable nextPageToken
to fetch next page.
Hope this helps!