blob: 594a505f382ae4d4e5e3bb12caa4836401196ba3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
import { Component } from '@angular/core';
import { FormBuilder } from '@angular/forms';
import { Router } from '@angular/router';
import { SearchService } from 'src/app/shared/services/search.service';
@Component({
selector: '.search',
templateUrl: './search.component.html',
styleUrls: ['./search.component.scss'],
})
export class SearchComponent {
searchForm = this.formBuilder.group({
by: 'name',
query: '',
});
constructor(
private search: SearchService,
private formBuilder: FormBuilder,
private router: Router
) {}
onSubmit(): void {
const by = this.searchForm.get('by')?.value;
const query = this.searchForm.get('query')?.value;
this.search.findResults(query, by);
this.router.navigate([`/search`, { by, query }]);
}
}
|