diff options
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 | } | ||