0
ngx-translate을 사용하여 태그 목록을 포함하여 내 앱을 통해 키워드를 번역합니다. 사용자는 모든 언어로 검색 할 수 있어야합니다. Observable/subscribe의 값을 가진 배열 필터링?
는 이전에 나는this.tag_array_filtered = this.tag_array.filter(tag =>
tag.toUpperCase().includes(this.tag_searched.toUpperCase()));
)
을하고 있었다 그러나 그것은뿐만 아니라 번역을 통해 핵심 단어를 검색 할 수 있습니다.
이 내가 번역 할 준비가 키의 배열입니다 핵심
this.translate.get(tag).subscribe(value => {
console.log(value);
})
변수 tag_array
에서 번역을 얻는 방법이다. tag_searched
은 사용자 입력을 포함합니다. tag_array_filtered
키 (안 번역)의 배열은
this.tag_array_filtered = this.tag_array.filter(tag =>
this.translate.get(tag.toUpperCase()).subscribe((value: string) => {
value.includes(this.tag_searched.toUpperCase())
})
)
어떻게 내 배열을 필터링 할 수 있습니다? 배열에서 변환 된 각 값을 사용자 입력과 비교하려고합니다.
손으로 만든 루프로 할 수 있지만 이미 존재하는 해결책이 있다면 훨씬 빠를 것입니다.