]>
Commit | Line | Data |
---|---|---|
f3aaa9a9 | 1 | import { Component, OnInit } from '@angular/core' |
66dc5907 | 2 | import { Router, NavigationEnd } from '@angular/router' |
f3aaa9a9 C |
3 | import { getParameterByName } from '../shared/misc/utils' |
4 | ||
5 | @Component({ | |
6 | selector: 'my-header', | |
7 | templateUrl: './header.component.html', | |
8 | styleUrls: [ './header.component.scss' ] | |
9 | }) | |
10 | ||
11 | export class HeaderComponent implements OnInit { | |
12 | searchValue = '' | |
13 | ||
14 | constructor (private router: Router) {} | |
15 | ||
16 | ngOnInit () { | |
66dc5907 C |
17 | this.router.events |
18 | .filter(e => e instanceof NavigationEnd) | |
19 | .map(() => getParameterByName('search', window.location.href)) | |
20 | .filter(searchQuery => !!searchQuery) | |
21 | .subscribe(searchQuery => this.searchValue = searchQuery) | |
f3aaa9a9 C |
22 | } |
23 | ||
24 | doSearch () { | |
f3aaa9a9 C |
25 | this.router.navigate([ '/videos', 'search' ], { |
26 | queryParams: { search: this.searchValue } | |
27 | }) | |
28 | } | |
29 | } |