问题标签 [angularjs-select2]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
angularjs - Updating Select2 selected elements when Angular model changes
I'm working on a project for deploying software through an AngularJS UI. On the current view, you have to select what environment a deployment is for. The possible list of environments is stored in the scope and is what the options for the select are built from:
Also on this page, there is a drop down that changes the current item that the environment is going to be set for. Choosing an existing item from the dropdown should take the Environments property from the existing item and select the correct elements in my Select2 box. This would then obviously update the transformParams.EnvironmentIds model. I've tried updating that model to change which environments are select but to no avail.
I've seen the bugfix to Angular 1.2 but I am stuck on 1.0.7 and don't have the option to upgrade Angular at this stage.
angularjs-select2 - 无法将 Select2 参数传递到 UI-select2
我正在尝试使用 ui-select2 Angular 指令,并且 github repo 指出:
所有 select2 选项都可以通过指令传递。您可以在 Select2 文档页面上阅读有关受支持的选项列表及其作用的更多信息
我的指令有效,但无法传递简单的选项(即:它们被忽略)。例如:
html
js
angularjs - 我的 angularjs 自定义 select2 指令出现问题
我已经为 angular 创建了自定义 select2 指令,它非常适合我的用例,并且在我使用模板时像魅力一样工作,它设置并从 input/ngModel 获取值但是当我在视图页面上使用它时,它不会通过范围解析 ngModel。$评估
这是范围问题,请帮助我,请找到下面提到的指令:
angularjs - 如何从查询处理程序中以角度隐藏 select2 下拉菜单?
我有一个从 ui-select2 调用的 select2 下拉菜单。我有一个自定义查询函数,可以进行 ajax 调用。
这是我的问题。如果 ajax 调用得到 401 - 例如用户会话超时 - 然后我的应用程序范围的处理程序智能地将用户重新路由到登录页面(实际上不是整个页面,只是部分页面),但下拉列表由 select2 控制还在,等待回调。
即使我使用query.callback({results:[]})下拉菜单发送空结果并显示“未找到结果”。
我如何告诉 select2,“忘记这个查询请求,暂时离开”?
示例代码:
问题是,如果我不告诉它,即使用户被重定向(实际上是部分)登录,下拉菜单仍然存在。
angularjs - angular-ui-select2嵌套的ng-repeat不起作用
我想显示一个结构
在使用角度选择选项内。
使用列表或其他元素效果很好,但使用 select2 时,结果是每个选项都显示一个连字符,例如- category
示例:http: //jsfiddle.net/WhLCM/
罪魁祸首:
<select class="input-medium" ui-select2 ng-model="category" type="text" >
<option ng-repeat="cat in categories" value="{{cat.name}}">
<span ng-repeat="a in cat.ancestors">-</span>
{{cat.name}}
</option>
</select>
angularjs - Default value on a Select2 with an ng-repeat with data coming from an API call
I have an angular select2 as follows:
in my controller, clients is set like this (calling a service that returns a $promise from a $resource):
I also set the initial value of $scope.newTicket.clientstate in the controller. Because the call to the $resource is asynchronous, the setting of the initial value happens before the query resolves.
I'm trying to get the dropdown to populate an initial value ("DEMO|DEMO") after the API call completes. I think that the solution is one of 3 things: setting ng-init on the select, setting ng-selected on the ng-repeat, or doing something in the .then() that happens after the API returns the query. I can't seem to get the right syntax to work however, and I was hoping to get some advice on how to proceed.
My first effort to solve things (you can see that in the comments below) was to convert everything to an ng-options, but the ui-select2 library is incompatable with ng-op[tions, so I'm looking for another possibility.
angularjs - AngularJs:选择绑定和http请求
我是 Angular js 的初学者,我遇到了 http 请求和绑定选择的问题。
我有一个表格中的选择菜单,填写如下:
我像这样在 html 中使用服务变量(我使用 select2 作为选择菜单):
目前一切正常。
我将服务变量保存在 localStorage 中,并在页面加载中恢复它。
但是,在这一步中,我有一个问题。该变量已从 localStorage 很好地加载,但它没有出现在选择中,它是空的。如果我不从 http 服务加载选择选项,一切正常。所以我认为我的选择菜单加载有问题。
我的代码有什么问题?
谢谢。
angularjs - ui-select2 和 ng-required
我在使用 ui-select2 组件的 require/ng-require 时遇到问题。出于可重用性的原因,我将 ui-select2 包装在自定义指令中,但无法获得使用它的要求。
这是 plunker:http ://plnkr.co/edit/2NaGvDWoEw14BN2few9W?p=preview
在没有指令的情况下尝试并且它正在工作:http ://plnkr.co/edit/uE698iFcUNnsYVF2fkOO?p=preview
angularjs - 多个select2 angularUI加载远程数据
我在多个 select2 中加载远程数据时遇到问题。我的代码是
它从获取请求中返回值,但是当我选择它时,它在输入框中返回未定义。
jquery - Select2 无限滚动组
所以这是一个有趣的情况,我还没有找到任何解决方案,我想知道这是否可能。我想要一个无限滚动(分页)的 select2 框,但我希望能够对结果进行分组。我知道的一件事是,我不需要将数据插入尚未完成的组中。这是一个用例:
一个 select2 框,将显示按年龄组排序的用户。我有一个 12-18 岁的年龄段,我只想一次拉回 10 个用户。如何将这些用户添加到 12-18 岁年龄段?