I am building a filter for finding city`s. I have an array with citynames. (this.place = [Londen, Amsterdam, Rome, Paris])
I have an inputfield when a user types a letter in the inputfield I want to search through the array and give him a list of suggestions.
I tried this but it does not work:
Html:
<input #inputValue (keyup)="filterValues($event)" />
<div *ngIf='placesFound'>
<span *ngFor="let place of placesFound">
{{place}}
</span>
</div>
TS file:
filterValues(event) {
let key = event.key
this.placesFound = this.places.filter(function(event) {
return this.places.indexOf(key) > -1
})
}
this does not work does someone has any suggestions?
thx!