diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-03-14 13:50:19 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-03-14 13:50:19 +0100 |
commit | dc8bc31be517a53e8fbe7100cfe45cd73f596de0 (patch) | |
tree | c0b0d6641dd352dafff93b8fd33ddb262b59aa47 /client/angular/videos/components/list/videos-list.component.ts | |
parent | bd324a669218f9ed302f7f54b36ee535d25c9733 (diff) | |
download | PeerTube-dc8bc31be517a53e8fbe7100cfe45cd73f596de0.tar.gz PeerTube-dc8bc31be517a53e8fbe7100cfe45cd73f596de0.tar.zst PeerTube-dc8bc31be517a53e8fbe7100cfe45cd73f596de0.zip |
Angular application :first draft
Diffstat (limited to 'client/angular/videos/components/list/videos-list.component.ts')
-rw-r--r-- | client/angular/videos/components/list/videos-list.component.ts | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/client/angular/videos/components/list/videos-list.component.ts b/client/angular/videos/components/list/videos-list.component.ts new file mode 100644 index 000000000..e5af87448 --- /dev/null +++ b/client/angular/videos/components/list/videos-list.component.ts | |||
@@ -0,0 +1,39 @@ | |||
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 | } | ||