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