]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/angular/videos/components/list/videos-list.component.ts
Angular application :first draft
[github/Chocobozzz/PeerTube.git] / client / angular / videos / components / list / videos-list.component.ts
1 import {Component, OnInit} from 'angular2/core';
2 import {ROUTER_DIRECTIVES} from 'angular2/router';
3
4 import {VideosService} from '../../services/videos.service';
5 import {Video} from '../../models/video';
6
7 @Component({
8 selector: 'my-videos-list',
9 styleUrls: [ 'app/angular/videos/components/list/videos-list.component.css' ],
10 templateUrl: 'app/angular/videos/components/list/videos-list.component.html',
11 directives: [ ROUTER_DIRECTIVES ]
12 })
13
14 export class VideosListComponent implements OnInit {
15 videos: Video[];
16
17 constructor(
18 private _videosService: VideosService
19 ) { }
20
21 ngOnInit() {
22 this.getVideos();
23 }
24
25 getVideos() {
26 this._videosService.getVideos().subscribe(
27 videos => this.videos = videos,
28 error => alert(error)
29 );
30 }
31
32 removeVideo(id: string) {
33 this._videosService.removeVideo(id).subscribe(
34 status => this.getVideos(),
35 error => alert(error)
36 )
37 }
38
39 }