问题标签 [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 不会填充
我有一个选择下拉列表,我想用对象中的用户名填充:
我的对象结构如下:
angularjs - AngularJS ng-repeat default value does not work
I am working with AngularJS and I am so new in that.
My aim is fill a tag SELECT with OPTION element from a datasource. That is what I do basically:
Everything works good, the Select is fill of my items, but I would like to set default value.
How you can see - I set my object model which is ng-model="Region" - I set its default value into init() function by $scope.Region = "003"; when the SELECT is loaded I do not why but dafault value is the first one "001"
I also tried to change value manually by in that case the SELECT gets the right value selection.
Anyone can explain why it does not work?
I know that is a common problem, I am already looked for that, any solution suggestion to use NG-OPTION, that directive works good, it can fill my SELECT with my array of object, it can select default value, very nice but it does not solve my problem because the value into the the option element id an integer autoincrement which is not what I want.
so in summary:
NG-REPEAT can render the SELECT how I want but default value does not work NG-OPTIONS can render the SELECT how I want, default value works but the value into option item cannot be set how I want.
any suggestions?
thanks in advance
EDIT
I found a "solution"
I do not like so much but works pretty good: - ng-init="init();" does not work good - If we exclude the initialize of default value into ng-init so EXCLUDE-ng-init="init();" and put the initilize when option are loded it works
Have a look at the code blow, I put {{init();}} after ng-repeat. Everithing works good {{item.DESC}} {{init();}}
I do not think is the best solution but Works, 1) I have a droopdown fill of my elements 2) The value of option into my list is CORRECT, "001", "002" and not a stupid autoincremental value which is useless.
I hope that can help someone... THANKS TO EVERYONE TRIED TO HELP ME
javascript - AngularJs:选择语句的 ng-option 没有被其他选择语句的 ng-model 过滤
嗨,我正在做的事情在 Angular Js 中可能不是一个好习惯。
这是我的html代码:
在 ng-change 搜索方法被调用....
搜索方法
调用方法后,我将 d2filteredstaffmembers 工作人员的来源设置为新值,但它没有显示任何更改。
任何想法?
angularjs - ng-options 显示数据,而 ng-repeat 不显示
我正在尝试使用 AngularJS 的 ng-repeat 指令显示一组数据。此 html 代码在同一个控制器下工作,并且具有与constants
变量更新异步相同的范围:
ng-options 适用于我的数据并显示constants
但 ng-repeat 的内容不是。
生成的 HTML 是这样的:
是的,数据来自异步调用,并且这个 html 通过 transclude 指令从模板生成,但就 ng-options 显示数据而言,所有这些通常的范围。$apply 的东西已经完成,在我看来它与问题无关,所以我省略了所有这些代码。问题是 - 为什么 ng-repeat 不能与能够使用的数据 ng-options 一起使用?ng-repeat 有什么特别之处?有什么我需要知道的问题吗?Ofc 如果我用这个 html 模板制作一个简单的控制器,那么这两个指令都可以工作。但我试图找到一个错误,它隐藏在这些指令如何处理数据的差异中。
谢谢!
PS:指令:
这是从 html 调用它的方式:
这是范围内的初始化函数:
常量包含这个:
AngularJS v1.2.10
angularjs - AngularJS - 设置下拉列表的选定值不起作用
我在这里复制了我的问题:http: //jsfiddle.net/U3pVM/2840/
正如标题所示,我无法设置使用 ng-options 填充的选择的选定值。
我已经搜索并尝试了我找到的所有可能的解决方案。任何帮助或建议将不胜感激!
HTML
角
javascript - 我需要一个选项来更新另一个角度
我有一个 plunker 设置http://plnkr.co/edit/fZ6akOYipzZ7ym8dliCV?p=preview
我希望第一个列表过滤下一个列表中的组。看起来它应该很简单,但我似乎无法让它按需要运行。任何帮助将不胜感激。
javascript - 如何静态或动态选择角度选择ngOption中的选项
我在http://www.bennadel.com/blog/2452-Mixing-Static-And-Dynamic-Data-In-An-AngularJS-Select-Menu.htm观看了一段视频,它几乎满足了我的需求。这个 Pluncker http://plnkr.co/edit/iy8mdpyg40ot8KEaOjz6?p=preview有一个例子,说明我如何使用 AngularJS 设置几个选择选项。我希望能够通过更改模型来设置选择列表中的一个/两个选项,或者只需一个单击事件就足以让我继续前进。
angularjs - 使用异步填充的选择编辑项目
我有一个需要编辑的项目表。单击编辑时,另一个控制器 (EditCtrl) 对其进行编辑。EditCtrl 使用 ajax 调用检索可能值的列表。我遇到的问题是下拉菜单没有选择的项目。
请参阅此示例http://plnkr.co/edit/mUciM4I37aN3lbC6ecIo?p=preview如果您单击保时捷,底部会显示“汽车颜色为红色”。但下拉菜单没有选择红色。