Angular ui-select2 - 隐藏组件的初始绘图/渲染 [英] Angular ui-select2 - hide initial drawing/rendering of component
问题描述
我正在评估将 Angular 与 ui-select2 结合使用,想知道是否有人可以帮助将 的闪烁/转换隐藏到 select2 组件中.
I'm evaluating using Angular with ui-select2 and wondered whether someone could provide help on hiding the flicker/conversion of the <select>
into the select2 component.
只是很简短,但用户可以看到组件更改样式.
It's only very brief, but users can see the component change styles.
有没有办法隐藏它直到select2修改了select?
Is there a way of hiding it until the select has been modified by select2?
推荐答案
我遇到了同样的问题,我查看了源代码.该指令稍后通过使用超时故意初始化.在代码中有一条注释说延迟初始化插件,以便注入的 DOM 不会破坏模板编译器".
I came across the same problem and I had a look at the source code. The directive is deliberately initialised later by using a timeout. In the code there is a comment saying "Initialize the plugin late so that the injected DOM does not disrupt the template compiler".
我的解决方案(你可以在这个 jsplunker 中看到它:http://plnkr.co/edit/fXjDxs?p=preview ) 是将选择标签的可见性设置为隐藏".
My solution (you can see it in this jsplunker: http://plnkr.co/edit/fXjDxs?p=preview ) is to set the visibility of the select tag to "hidden".
<select ui-select2 ng-model="....." style="visibility: hidden; ">......
加载组件时,该标记将替换为 div.在 ui-select2.js 中,我添加了一行(第 208 行)以将其可见性设置为可见".
When the component is loaded that tag is replaced with a div. In ui-select2.js I have added a line (line 208) to set its visibility to "visible".
elm.prev().css({"visibility": "visible"});
这篇关于Angular ui-select2 - 隐藏组件的初始绘图/渲染的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!