问题标签 [ng-options]
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 - 将 ngOptions 与对象一起使用,其中键是数组并按键分组
我有一个对象,其中键的值是数组:例如:
我想在选择框中显示所有“项目”并按“键”对它们进行分组
我怎样才能用 ng-options 做到这一点?我阅读了文档,但似乎无法弄清楚如何做到这一点。
angularjs - Setting selected values for ng-options bound select elements
Fiddle with the relevant code: http://jsfiddle.net/gFCzV/7/
I'm trying to set the selected value of a drop down that is bound to a child collection of an object referenced in an ng-repeat. I don't know how to set the selected option since I can't reference the collection it's being bound to in any way that I'm aware of.
HTML:
JS:
Is this the one case where I should actually be using ng-init with a SelectedIndex on the model?
angularjs - ng-options creates an empty option at the end when listbox group heading is clicked
I am stuck on this particular issue with ng-options. I am creating a listbox with option grouping:
When I click on a group heading (Type1 or Type2), Chrome creates an empty option at the end and marks it selected. I believe it has something to do with the selection because it may not find anything 'selected' when a header is clicked, but an empty value at the bottom is not desired.
Please see the fiddle here.How can i fix it?
(The code works fine in IE9, although not sure why the fiddle doesn't)
angularjs - 如何禁用一个
当我们在 AngularJS 中填充 ng-options时,有没有办法禁用元素option
中的an?select
options
像这样:http ://www.w3schools.com/tags/att_option_disabled.asp
您可以通过添加ng-disabled
到每个<option>
标签来做到这一点,但是如果我们ng-options
在标签中使用指令,有没有办法做到这一点select
?
javascript - ng-bind-html 不适用于 ng-options
我需要清理选项中的特殊字符,但它不能正常工作。也许有人可以告诉我我应该如何正确地做到这一点?
例如:
HTML:
JS:
var app = angular.module('app', ['ngSanitize']);
这是小提琴上的链接:http: //jsfiddle.net/rfTV2/3/
javascript - ngOptions 二级对象显示
我有这个结构:
问题是:我如何编写 ngOptions attrbiute 来像这样输出这个对象?:
此外 - ngRepeat 不是一个选项。我必须单独执行此 ngOptions 才能使插件正常工作。
javascript - 在两个数组之间移动对象
我有两个由包含对象的数组组成的列表。我正在尝试将对象从一个列表移动到另一个列表,反之亦然。
控制器:
服务:
目的:
HTML:
现在,推送到分配的组是有效的,但只有当我点击其他内容或列表时才会更新,而不是真正动态地更新。但最大的问题是.pop()
我认为没有按预期工作。
angularjs - ng-change 方法未执行
我正在尝试传递在 a 中选择的对象来更新另一个对象的数据。这是html
这呈现
这是我的更新功能
我的问题是,现在当所选项目更改时 updateCategory 方法不会触发。我希望在<select></select>
我的 $scope.updateCategory 方法触发的更改中选择的选项。如果我可以将选择的类别传递给此方法,那也很棒。
此处更新是填充数组类别的我的初始化
javascript - 使用 ng-options angular js 过滤 json 对象
我在使用 AngularJS 将 json 对象过滤到选择表单元素时遇到问题。这是我到目前为止所得到的。我很难过,任何帮助将不胜感激。
应用程序.js:
单页应用程序.html:
当前结果:
期望的结果:
javascript - 使用Angularjs将数组值设置为下拉
我是 Angularjs 的新手。这是我的场景。
我有一个数组
numbers = ['1','2','3'];
并且还有一个
<select id="fileNumber" ng-model="files"></select>
如何将数组的值添加到下拉列表fileNumber
我试过了,
ng-options="numbers"
谁能说如何将数组值包含到下拉列表中。