简体   繁体   English

AngularJS:从嵌套的ng-repeat表单中获取值

[英]AngularJS: getting values from nested ng-repeat form

I am new to AngularJS , I successfully designed the repeated forms using nested ng-repeat . 我是AngularJS新手,我使用嵌套的ng-repeat成功设计了重复的表格。 But I can't find the right way to get all values corresponding to the forms. 但我找不到正确的方法来获取与表格相对应的所有值。

Here is my updated JSFiddle: http://jsfiddle.net/MrSuS/gTc5v/7/ 这是我更新的JSFiddle: http //jsfiddle.net/MrSuS/gTc5v/7/

Update: And you can see, radio input is also not working properly. 更新:你可以看到,无线电输入也无法正常工作。

there is no binding in your application use ng-model to bind your field values. 您的应用程序中没有绑定使用ng-model绑定您的字段值。

if you want to design custom form depends on your dynamic data you should write a directive like this Example Form Directive 如果你想设计自定义表单取决于你的动态数据,你应该写一个像这个示例表格指令的指令

UPDATE UPDATE

I think best way is repeat html form in your position. 我认为最好的方法是在你的位置重复html表单。 It is simple, easy and less code... 它简单,容易,代码少...

<div ng-repeat="form in forms">
    <h2>{{form.name}}</h2>
    <input type="text" ng-model="form.answer.city"><br/>
    ...

here is JSFIDDLE example... 这是JSFIDDLE的例子......

Firstly use ng-model for binding. 首先使用ng-model进行绑定。 Second, use $index as array subscript for your ng-model 其次,使用$index作为ng-model数组下标

 ng-model="input[$index]"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM