From 98b01bac2c2c4536aa97d826b61516657f4d15f5 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 14 Mar 2016 22:16:43 +0100 Subject: Angular 2 : draft 2 --- client/angular/app/app.component.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'client/angular/app/app.component.ts') diff --git a/client/angular/app/app.component.ts b/client/angular/app/app.component.ts index 3d41183f2..cb961a3c8 100644 --- a/client/angular/app/app.component.ts +++ b/client/angular/app/app.component.ts @@ -1,6 +1,6 @@ import { Component, ElementRef } from 'angular2/core'; -import { RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS } from 'angular2/router'; -import {HTTP_PROVIDERS} from 'angular2/http'; +import { RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS, Router } 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'; @@ -36,15 +36,22 @@ import { FriendsService } from '../friends/services/friends.service'; }) export class AppComponent { - constructor(private _friendsService: FriendsService) {} + constructor(private _friendsService: FriendsService, private _router: Router) {} + + doSearch(search: string) { + if (search !== '') { + this._router.navigate(['VideosList', { search: search }]); + } else { + this._router.navigate(['VideosList']); + } + } makeFriends() { this._friendsService.makeFriends().subscribe( status => { if (status === 409) { alert('Already made friends!'); - } - else { + } else { alert('Made friends!'); } }, -- cgit v1.2.3