From 6af662a5961b48ac12682df2b8b971060a2cc67d Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Sat, 25 Jan 2020 16:32:06 +0100 Subject: Add keyboard navigation and hepler to typeahead --- client/src/app/header/suggestions.component.ts | 31 ++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 client/src/app/header/suggestions.component.ts (limited to 'client/src/app/header/suggestions.component.ts') diff --git a/client/src/app/header/suggestions.component.ts b/client/src/app/header/suggestions.component.ts new file mode 100644 index 000000000..122c09388 --- /dev/null +++ b/client/src/app/header/suggestions.component.ts @@ -0,0 +1,31 @@ +import { Input, QueryList, Component, Output, AfterViewInit, EventEmitter, ViewChildren } from '@angular/core' +import { SuggestionComponent } from './suggestion.component' + +@Component({ + selector: 'my-suggestions', + template: ` + + ` +}) +export class SuggestionsComponent implements AfterViewInit { + @Input() results: any[] + @Input() highlight: string + @ViewChildren(SuggestionComponent) listItems: QueryList + @Output() init = new EventEmitter() + + ngAfterViewInit () { + this.init.emit({ items: this.listItems }) + this.listItems.changes.subscribe( + val => this.init.emit({ items: this.listItems }) + ) + } + + hoverItem (index: number) { + this.init.emit({ items: this.listItems, index: index }) + } +} -- cgit v1.2.3