如何在 Angular 6 中使用 select2?
我需要在 angular 6 中使用select2"来自动完成.谁以前用过?,请帮帮我.
I need to use "select2" in angular 6 for autocomplete. Who's ever use it before? , help me please.
以防万一其他人来到这里.Select2 有很多角度包装器的分支,但它们都很大,并且还需要 JQuery (1.32MB) 和 Select2 (839kB).
Just in case anyone else landed here. There are lots of forks of angular wrappers for Select2 but they all sizeable and also require both JQuery (1.32MB) and Select2 (839kB).
如果您对没有任何依赖项的纯 Angular 的 Select2 的简化克隆感兴趣,您可以尝试这个:
If you are interested in a simplified clone of Select2 in pure angular without any dependencies you could try this one:
https://github.com/timbophillips/angular-components-workspace/tree/master/projects/filtered-select
https://www.npmjs.com/package/filtered-select
花里胡哨要少得多,但就我而言,我真的只想要可搜索的选择控件.
Far fewer bells and whistles but for my purposes I really just want the searchable select control.
将其安装为 npm 模块 (16.2kB) 或使用源代码.它在没有 Ivy 的情况下编译,所以它应该适用于旧的和新的 angular 项目.
Install it as an npm module (16.2kB) or use the source code. Its compiled without Ivy so it should work on old and new angular projects.