angularjs search and ignore spanish characters

前端 未结 5 1944
名媛妹妹
名媛妹妹 2020-12-15 14:03

I\'m adding a simple sort on a page. The idea is to search products. These products are written in spanish language and has accents. For example: \'Jamón\'.

Here is

5条回答
  •  心在旅途
    2020-12-15 15:07

    JavaScript has a neat function for this, called localeCompare, where you can specify sensitivity = base, an option that makes it treat á and a as equivalent, but it is not widely supported. I think your only option is to create a filter function wherein you normalise both strings manually (replacing ó with o and so on) and compare the results.

提交回复
热议问题