aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/header/suggestions.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/header/suggestions.component.ts')
-rw-r--r--client/src/app/header/suggestions.component.ts31
1 files changed, 31 insertions, 0 deletions
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 @@
1import { Input, QueryList, Component, Output, AfterViewInit, EventEmitter, ViewChildren } from '@angular/core'
2import { SuggestionComponent } from './suggestion.component'
3
4@Component({
5 selector: 'my-suggestions',
6 template: `
7 <ul role="listbox" class="p-0 m-0">
8 <li *ngFor="let result of results; let i = index" class="d-flex flex-justify-start flex-items-center p-0 f5"
9 role="option" aria-selected="true" (mouseenter)="hoverItem(i)">
10 <my-suggestion [result]="result" [highlight]="highlight"></my-suggestion>
11 </li>
12 </ul>
13 `
14})
15export class SuggestionsComponent implements AfterViewInit {
16 @Input() results: any[]
17 @Input() highlight: string
18 @ViewChildren(SuggestionComponent) listItems: QueryList<SuggestionComponent>
19 @Output() init = new EventEmitter()
20
21 ngAfterViewInit () {
22 this.init.emit({ items: this.listItems })
23 this.listItems.changes.subscribe(
24 val => this.init.emit({ items: this.listItems })
25 )
26 }
27
28 hoverItem (index: number) {
29 this.init.emit({ items: this.listItems, index: index })
30 }
31}