I'll try my best to explain my scenario. I have a search filter which works when used in the following format in Angular 4:
<select [(ngModel)]="city_filter" (change)="applyFilter('city',$event.target.value)">
<option value="Ahmedabad">Ahmedabad</option>
<option value="Bangalore">Bangalore</option>
<option value="Bengaluru">Bengaluru</option>
<option value="Delhi">Delhi</option>
<option value="Dilli">Dilli</option>
</select>
It stops working when I try the method:
<select [(ngModel)]="city_filter" (change)="applyFilter('city',$event.target.value)">
<option value="Ahmedabad">Ahmedabad</option>
<option value="Bangalore/Bengaluru">Bangalore/Bengaluru</option>
<option value="Delhi/Dilli">Delhi/Dilli</option>
</select>
How do I make this work so that the filter works for both Bangalore/Bengaluru?
In the applyFilter
, this is the function:
applyFilter (key: string, value) {
this.filter.set(key, value);
if (value === 'null') {
this.filter.delete(key);
}
let p = new HttpParams();
this.filter.forEach((v, k) => {
p = p.append(k, v);
});
this.loading = true;
this.jobService.searchJob(p).subscribe(res => {
this.loading = false;
this.valueStack = res;
this.jobs = res.jobs || [];
}, err => {
this.loading = false;
this.jobs = [];
});
}
ngModel
. I assume this was just an accident though because neither of these code scenarios would work for you then.applyFilter
function? I don't see anything wrong with this html./
. The person below mentions this. Try what they're saying, I won't bother adding another answer that says the same.