如何在Angular 6中使用select2? [英] How to use select2 in Angular 6?

查看:154
本文介绍了如何在Angular 6中使用select2?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在角度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).

如果您对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的情况下进行编译,因此可以在新旧的角度项目中使用.

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.

这篇关于如何在Angular 6中使用select2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆