传递给
我有一个表单wth autocomplete,它在本地运行良好,但当我将其编译为pwa时,它不会过滤数据。api运行良好,并返回数据json数组响应
var normalize = function (term) {
var ret = "";
for (var i = 0; i < term.length; i++) {
ret += accentMap[term.charAt(i)] || term.charAt(i);
}
return ret;
};
search(Objobs: { Objobs?: any; id?: any; }, filter: { name: string } = { name: '' }, page = 1): Observable<IUserResponse> {
return this.http.get<IUserResponse>('https://tutututu.com/agriobs-codeigniter/index.php/structure/get_area/17' ).pipe(
tap((response: IUserResponse) => {
response.results = response.results
// Not filtering on mobile device (Android, Ios) !
.map(user => new User(user.id_commune, user.nom_commune))
.filter(user => normalize(user.nom_commune.toLowerCase()).includes(filter.name))
return response;
//console.log(response);
})
)
}
tap
的Lambda的返回值被忽略,因为tap
不会改变流中的值。此外,目前还不清楚filter.name
的来源。
我会将tap
更改为map
。看起来可能是这样的:
return this.http.get<IUserResponse>('https://tutututu.com/agriobs-codeigniter/index.php/structure/get_area/17' ).pipe(
map((response: IUserResponse) => {
response.results = response.results
.map(user => new User(user.id_commune, user.nom_commune))
.filter(user => normalize(user.nom_commune.toLowerCase()).includes(filter.name))
return response;
})
);
很抱歉这是变音符号自动完成转换问题!