1 import { Input, QueryList, Component, Output, AfterViewInit, EventEmitter, ViewChildren, ChangeDetectionStrategy } from '@angular/core'
2 import { SuggestionComponent } from './suggestion.component'
5 selector: 'my-suggestions',
6 templateUrl: './suggestions.component.html',
7 changeDetection: ChangeDetectionStrategy.OnPush
9 export class SuggestionsComponent implements AfterViewInit {
10 @Input() results: any[]
11 @Input() highlight: string
12 @ViewChildren(SuggestionComponent) listItems: QueryList<SuggestionComponent>
13 @Output() init = new EventEmitter()
16 this.listItems.changes.subscribe(
17 _ => this.init.emit({ items: this.listItems })
21 hoverItem (index: number) {
22 this.init.emit({ items: this.listItems, index: index })