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.listItems.changes.subscribe(
val => this.init.emit({ items: this.listItems })
)
}
hoverItem (index: number) {
this.init.emit({ items: this.listItems, index: index })
}
}