angular2-youtube
Installation
To install this library, run:
$ npm install angular2-youtube --save
Consuming your library
Once you have published your library to npm, you can import your library in any Angular application by running:
$ npm install angular2-youtube
and then from your Angular AppModule
:
;; ; // Import your library;
Once your library is imported, you can use its components, directives and pipes in your Angular application you need to implement your Component like this example below:
import { Component } from '@angular/core'; // Import your Service and Modelimport { YoutubePlaylistService,Playlist } from 'angular2-youtube'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css']}) export class AppComponent { private playlist:Playlist[]; private playlistYoutube:any; private msgErro: string; constructor(private youtubePlaylist:YoutubePlaylistService) { } getplaylist() { this.playlistYoutube = this.youtubePlaylist.getplaylist("YOU KEY GOOGLE CONSOLE","YOUR PLAYLIST ID") .subscribe(value => { this.playlistYoutube = value console.log(this.playlistYoutube) console.log(this.playlistYoutube.items) }); console.log('s'); } nextPage(pageToken:string){ this.playlistYoutube = this.youtubePlaylist.playlistList_page("YOU KEY GOOGLE CONSOLE","YOUR PLAYLIST ID",pageToken).subscribe(value => { this.playlistYoutube = value console.log(this.playlistYoutube) console.log(this.playlistYoutube.items) }); } ngOnInit(){ this.getplaylist(); } }
Now We need to implement our Template like this example below:
Voltar {{playlistYoutube.nextPageToken}} Proximo {{v.snippet.title}}
In this example above, We don't use the bootstrap and outher style, We just implemented our service.
License
MIT © Thiago da Silva Adriano