angular.js - How to submit a form to the server after using ng-repeat in angular?
仅有的幸福
仅有的幸福 2017-05-15 16:51:06
0
1
696

Suppose there is such an object:

var obj ={
    {a:1,b:2,c:3},
    {a:4,b:5,c:6},
    {a:7,b:8,c:9},
}

Used ng-repeat data in obj to display the list, and then modified the value of C through the input box (it should be two-way bound). Then how to submit the specified items in this form (columns a and c)?

<form name="test">
<th>a</th>
<th>b</th>
<th>c</th>
<p ng-repeat='data in obj'>
<tr><td>data.a</td><td>data.b</td><td>data.c</td></tr> 
</p>
<form>
<button>.....

I don’t understand something, I hope you can explain it, maybe the html file is not written correctly
Thank you all in advance

仅有的幸福
仅有的幸福

reply all(1)
淡淡烟草味

Correction

  • The poster’s obj应该绑在$scope中,如$scope.obj=...,而且obj should be an array
  • td中的数据应该加花括号如:{{data.a}}

Answer

  • This is required if the form submission is normalname属性的,而且都应该是表单域之类的吧,比如input,select
  • Andangular既然已经数据绑定了,直接在C里面拿到数据,然后异步提交就可以了,用$http这个service
  • Currently I only know this method~
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template