travopti/frontend/src/app/containers/search/search.component.ts
2020-06-17 19:13:16 +02:00

35 lines
862 B
TypeScript

import {Component, ElementRef, OnInit, ViewChild} from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import {Result} from '../../interfaces/result.interface';
import {MOCK_RESULT} from '../../mock/mock-data';
@Component({
selector: 'app-search',
templateUrl: './search.component.html',
styleUrls: ['./search.component.scss']
})
export class SearchComponent implements OnInit {
queryString: string;
results: Result[];
@ViewChild('result', {static: false})
resultDiv: ElementRef;
constructor(private route: ActivatedRoute) {
}
ngOnInit() {
this.route.queryParams.subscribe(params => {
this.queryString = params.q;
});
// Mock results
setTimeout(() => {
this.results = MOCK_RESULT;
this.resultDiv.nativeElement.scrollIntoView({behavior: 'smooth', block: 'start'});
}, 1000);
}
}