1 import { Component } from '@angular/core';
2 import { HTTP_PROVIDERS } from '@angular/http';
3 import { RouteConfig, Router, ROUTER_DIRECTIVES, ROUTER_PROVIDERS } from '@angular/router-deprecated';
5 import { FriendService } from './friends/index';
6 import { Search, SearchComponent } from './shared/index';
11 } from './users/index';
17 } from './videos/index';
23 component: UserLoginComponent
28 component: VideoListComponent,
32 path: '/videos/watch/:id',
34 component: VideoWatchComponent
39 component: VideoAddComponent
45 templateUrl: 'client/app/app.component.html',
46 styleUrls: [ 'client/app/app.component.css' ],
47 directives: [ ROUTER_DIRECTIVES, SearchComponent ],
48 providers: [ ROUTER_PROVIDERS, HTTP_PROVIDERS, VideoService, FriendService, AuthService ]
51 export class AppComponent {
53 search_field: string = name;
56 constructor(private _friendService: FriendService,
57 private _authService: AuthService,
58 private _router: Router
61 this.isLoggedIn = this._authService.isLoggedIn();
63 this._authService.loginChanged$.subscribe(
65 if (status === AuthStatus.LoggedIn) {
66 this.isLoggedIn = true;
72 onSearch(search: Search) {
73 if (search.value !== '') {
78 this._router.navigate(['VideosList', params]);
80 this._router.navigate(['VideosList']);
85 // this._authService.logout();
89 this._friendService.makeFriends().subscribe(
92 alert('Already made friends!');
94 alert('Made friends!');
102 this._friendService.quitFriends().subscribe(
104 alert('Quit friends!');
106 error => alert(error)