Angular.js Chosen integration

一曲冷凌霜 提交于 2019-12-04 03:31:37

You should maybe try http://angular-ui.github.com/

It's a suite of angular directives. Among them you'll find 'select2' directive which serves as a proxy to Chosen plugin (Select2 plugin to be precise).

Your solution won't work because jQuery code would fire before the element is actually created in the DOM. You should solve this problem using a directive on the form element.

Element needs to be created dynamically and therefore you are in fact operating on the DOM element - perfect fit for Angular's directives. No use of jQuery is necessary and try to avoid it while working with Angular. Note that jQuery is still required due to Chosen dependencies.

I solve the problem using this set:

  1. angular-chosen directive https://github.com/localytics/angular-chosen
  2. [OPTIONAL] Bootstrap3 styling https://github.com/alxlit/bootstrap-chosen

I suggest you to try writing the directive yourself. It's a nice practice. You can try with this: http://www.youtube.com/watch?v=8ozyXwLzFYs

Good luck!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!