From 9aa46b0c7bade696a477626ad7590ffdd281e03c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sun, 21 Aug 2016 11:21:45 +0200 Subject: Client: navigate to /videos/list when do search on another page --- client/src/app/shared/search/search.component.ts | 7 ++++++- client/src/app/shared/search/search.service.ts | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'client') diff --git a/client/src/app/shared/search/search.component.ts b/client/src/app/shared/search/search.component.ts index 219997e85..853f5dc7c 100644 --- a/client/src/app/shared/search/search.component.ts +++ b/client/src/app/shared/search/search.component.ts @@ -1,4 +1,5 @@ import { Component, OnInit } from '@angular/core'; +import { Router } from '@angular/router'; import { DROPDOWN_DIRECTIVES} from 'ng2-bootstrap/components/dropdown'; @@ -25,7 +26,7 @@ export class SearchComponent implements OnInit { value: '' }; - constructor(private searchService: SearchService) {} + constructor(private searchService: SearchService, private router: Router) {} ngOnInit() { // Subscribe if the search changed @@ -58,6 +59,10 @@ export class SearchComponent implements OnInit { } doSearch() { + if (this.router.url.indexOf('/videos/list') === -1) { + this.router.navigate([ '/videos/list' ]); + } + this.searchService.searchUpdated.next(this.searchCriterias); } diff --git a/client/src/app/shared/search/search.service.ts b/client/src/app/shared/search/search.service.ts index c7993db3d..717a7fa50 100644 --- a/client/src/app/shared/search/search.service.ts +++ b/client/src/app/shared/search/search.service.ts @@ -1,5 +1,6 @@ import { Injectable } from '@angular/core'; import { Subject } from 'rxjs/Subject'; +import { ReplaySubject } from 'rxjs/ReplaySubject'; import { Search } from './search.model'; @@ -12,6 +13,6 @@ export class SearchService { constructor() { this.updateSearch = new Subject(); - this.searchUpdated = new Subject(); + this.searchUpdated = new ReplaySubject(1); } } -- cgit v1.2.3