From dc8bc31be517a53e8fbe7100cfe45cd73f596de0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 14 Mar 2016 13:50:19 +0100 Subject: Angular application :first draft --- client/angular/app/app.component.ts | 63 +++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 client/angular/app/app.component.ts (limited to 'client/angular/app/app.component.ts') diff --git a/client/angular/app/app.component.ts b/client/angular/app/app.component.ts new file mode 100644 index 000000000..3d41183f2 --- /dev/null +++ b/client/angular/app/app.component.ts @@ -0,0 +1,63 @@ +import { Component, ElementRef } from 'angular2/core'; +import { RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS } from 'angular2/router'; +import {HTTP_PROVIDERS} from 'angular2/http'; + +import { VideosAddComponent } from '../videos/components/add/videos-add.component'; +import { VideosListComponent } from '../videos/components/list/videos-list.component'; +import { VideosWatchComponent } from '../videos/components/watch/videos-watch.component'; +import { VideosService } from '../videos/services/videos.service'; +import { FriendsService } from '../friends/services/friends.service'; + +@RouteConfig([ + { + path: '/videos/list', + name: 'VideosList', + component: VideosListComponent, + useAsDefault: true + }, + { + path: '/videos/watch/:id', + name: 'VideosWatch', + component: VideosWatchComponent + }, + { + path: '/videos/add', + name: 'VideosAdd', + component: VideosAddComponent + } +]) + +@Component({ + selector: 'my-app', + templateUrl: 'app/angular/app/app.component.html', + styleUrls: [ 'app/angular/app/app.component.css' ], + directives: [ ROUTER_DIRECTIVES ], + providers: [ ROUTER_PROVIDERS, HTTP_PROVIDERS, ElementRef, VideosService, FriendsService ] +}) + +export class AppComponent { + constructor(private _friendsService: FriendsService) {} + + makeFriends() { + this._friendsService.makeFriends().subscribe( + status => { + if (status === 409) { + alert('Already made friends!'); + } + else { + alert('Made friends!'); + } + }, + error => alert(error) + ) + } + + quitFriends() { + this._friendsService.quitFriends().subscribe( + status => { + alert('Quit friends!'); + }, + error => alert(error) + ) + } +} -- cgit v1.2.3