- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在这里,我在自动完成下拉列表中获得了国家/地区列表,并尝试通过国家名称的开头字母来过滤这些国家/地区。
示例:如果我们输入“Aus”,所有带有“aus”的国家名称都会被过滤掉。 (见截图)。我只想过滤“澳大利亚和奥地利”或任何其他以“Aus”开头的国家/地区名称。
怎么做?
<ng-autocomplete #countryList formControlName="locationCountry" [data]="countries"
min-length="1" [searchKeyword]="countrykeyword"
[initialValue]="countrykeyword"
(selected)='selectEventCountry($event);onLocationSubmit();'
(inputCleared)='onCountryCleared($event, false)'
[itemTemplate]="countryListTemplate"
[notFoundTemplate]="notFoundTemplate" placeHolder="Enter Country">
</ng-autocomplete>
最佳答案
根据Angular AutoComplete Inputs ,
输入 | 说明 |
---|---|
自定义过滤器 | 自定义过滤功能。您可以使用它来提供自己的过滤功能,例如模糊匹配过滤,或完全禁用过滤(只需通过 (items) => items 作为过滤器)。不要更改给定的 items 参数,而是返回过滤列表。 |
您可以定义自定义过滤器逻辑并将其传递给 [customFilter]
@Input 属性。
.component.html
<ng-autocomplete #countryList formControlName="locationCountry"
[data]="countries"
min-length="1"
[searchKeyword]="countrykeyword"
[initialValue]="countrykeyword"
(selected)='selectEventCountry($event);onLocationSubmit();'
(inputCleared)='onCountryCleared($event, false)'
[itemTemplate]="countryListTemplate"
[notFoundTemplate]="notFoundTemplate"
placeholder="Enter Country"
[customFilter]="customFilter">
</ng-autocomplete>
.component.ts
export class AppComponent {
...
customFilter = function(countries: any[], query: string): any[] {
return countries.filter(x => x.name.toLowerCase().startsWith(query.toLowerCase()));
};
}
关于Angular Autocomplete - 通过单词的起始字母过滤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67980568/
我在尝试生成具有“价格”轴和“量”轴的图表时遇到问题,类似于 example given 中的图表。在 Highstock 网站上。它可以很好地显示成交量轴,但不能显示价格。 在尝试确定问题的原因时,
起始 - HTML
在我的 HTML 项目中,我试图提及 标签。但是,VS Code 将其解释为实际的 标签,它会导致奇怪的事情发生。有人有办法解决这个问题吗?预先感谢您! 最佳答案 使用<代替 . 顺便说一下,使
起始 - HTML
在我的 HTML 项目中,我试图提及 标签。但是,VS Code 将其解释为实际的 标签,它会导致奇怪的事情发生。有人有办法解决这个问题吗?预先感谢您! 最佳答案 使用<代替 . 顺便说一下,使
The allocation function attempts to allocate the requested amount of storage. If it is successful, i
这是我的Program.cs: public static void Main(string[] args) { var host = new WebHostBuilder()
我希望我的应用程序独立于操作系统。因此,我的 config.properties 和日志文件存储在资源文件夹中,我通过相对路径获取这些资源。这是我的项目结构。 这是我的 AppConfig 类: pu
(前言:这是我在 Stack Overflow 上提出的第一个与音频相关的问题,因此我会尽力用最好的措辞来表达。欢迎编辑。) 我正在创建一个允许用户循环播放音乐的应用程序。目前,我们的原型(proto
我有一个 Pandas DataFrame,我想将其用作 Scrapy Start URL,函数 get_links 打开一个到 DataFrame 的 xlsx,其中有一个我想在其上运行蜘蛛的 Co
我有几个大的 DTD 文件。我用过 trang将它们转换为 XSD 文件,这样我就可以轻松地从 JAXB 和其他实用程序中使用它。但是,生成的 XSD 文件的所有声明元素都位于顶层。这意味着任何元素都
是否有任何工具可以将文件从给定的起始偏移量复制到给定的(结束)偏移量。我还想通过运行 md5sum 确认该工具已正确复制指定的字节。像这样的东西 1) Copy source file star
所以,我有一个程序,我可以使用 Path2D 对象将形状添加到 JPanel,然后我可以单击并拖动它们。我想要做的是能够找到药物后形状的最终 X 和 Y 坐标。坐标必须是左上角坐标。有什么想法吗? /
我是一名优秀的程序员,十分优秀!