Javascript 带数据的角度提交表
我有一个要求,即我有一个包含(8*6)48个单元格的表,其中所有单元格都在Javascript 带数据的角度提交表,javascript,jquery,html,angularjs,spring-mvc,Javascript,Jquery,Html,Angularjs,Spring Mvc,我有一个要求,即我有一个包含(8*6)48个单元格的表,其中所有单元格都在内有输入标记,提交该表时,我的js文件必须获取所有数据并将其发布到我的后端控制器。我的问题是,由于所有单元格都是输入文本类型,angular无法获取其中的值 var isrcorderapp=angular.module('plunker',[]); /* 指令(“test1”,函数(){ 返回{ 限制:'A', 链接:函数($scope$elem){ var arr=($($elem[0]).find('tbody t
内有输入标记,提交该表时,我的js文件必须获取所有数据并将其发布到我的后端控制器。我的问题是,由于所有单元格都是输入文本类型,angular无法获取其中的值
var isrcorderapp=angular.module('plunker',[]);
/*
指令(“test1”,函数(){
返回{
限制:'A',
链接:函数($scope$elem){
var arr=($($elem[0]).find('tbody tr');
var coll=[];
对于(变量i=0;i
安古拉斯普朗克
文件。写(“”);
名称
年龄
位置
办公室
名称
年龄
位置
办公室
老虎尼克松
爱丁堡
伦敦
纽约
旧金山
东京
而不是:
obj.push(tdColl[y].innerHTML);
尝试:
我从你的描述中了解到了什么
HTML:
<!DOCTYPE html>
<html ng-app="plunker">
<head>
<meta charset="utf-8" />
<title>AngularJS Plunker</title>
<script>
document.write('<base href="' + document.location + '" />');
</script>
<link rel="stylesheet" href="style.css" />
<script data-require="angular.js@1.3.x" src="https://code.angularjs.org/1.3.20/angular.js" data-semver="1.3.20"></script>
<script src="app.js"></script>
</head>
<body ng-controller="isrcorders">
<form ng-submit="myFn()">
<table test1="" id="isrctable" class="table">
<thead>
<tr>
<th>Name</th>
<th>Age</th>
<th>Position</th>
<th>Office</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Name</th>
<th>Age</th>
<th>Position</th>
<th>Office</th>
</tr>
</tfoot>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>
<input type="text" ng-model="table.rowone.age">
</td>
<td>
<input type="text" ng-model="table.rowone.position">
</td>
<td>
<select ng-model="table.rowone.office">
<option value="Edinburgh">
Edinburgh
</option>
<option value="London">
London
</option>
<option value="New York">
New York
</option>
<option value="San Francisco">
San Francisco
</option>
<option value="Tokyo">
Tokyo
</option>
</select>
</td>
</tr>
<tr>
<td>yoyo baby</td>
<td>
<input type="text" ng-model="table.rowtwo.age">
</td>
<td>
<input type="text" ng-model="table.rowtwo.position">
</td>
<td>
<select ng-model="table.rowtwo.office">
<option value="Edinburgh">
Edinburgh
</option>
<option value="London">
London
</option>
<option value="New York">
New York
</option>
<option value="San Francisco">
San Francisco
</option>
<option value="Tokyo">
Tokyo
</option>
</select>
</td>
</tr>
</tbody>
</table>
<button ng-click="submitTable(table)">Submit</button>
</form>
<pre>{{tableval | json}}</pre>
</body>
</html>
PLnkr:我得到的结果是
<!DOCTYPE html>
<html ng-app="plunker">
<head>
<meta charset="utf-8" />
<title>AngularJS Plunker</title>
<script>
document.write('<base href="' + document.location + '" />');
</script>
<link rel="stylesheet" href="style.css" />
<script data-require="angular.js@1.3.x" src="https://code.angularjs.org/1.3.20/angular.js" data-semver="1.3.20"></script>
<script src="app.js"></script>
</head>
<body ng-controller="isrcorders">
<form ng-submit="myFn()">
<table test1="" id="isrctable" class="table">
<thead>
<tr>
<th>Name</th>
<th>Age</th>
<th>Position</th>
<th>Office</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Name</th>
<th>Age</th>
<th>Position</th>
<th>Office</th>
</tr>
</tfoot>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>
<input type="text" ng-model="table.rowone.age">
</td>
<td>
<input type="text" ng-model="table.rowone.position">
</td>
<td>
<select ng-model="table.rowone.office">
<option value="Edinburgh">
Edinburgh
</option>
<option value="London">
London
</option>
<option value="New York">
New York
</option>
<option value="San Francisco">
San Francisco
</option>
<option value="Tokyo">
Tokyo
</option>
</select>
</td>
</tr>
<tr>
<td>yoyo baby</td>
<td>
<input type="text" ng-model="table.rowtwo.age">
</td>
<td>
<input type="text" ng-model="table.rowtwo.position">
</td>
<td>
<select ng-model="table.rowtwo.office">
<option value="Edinburgh">
Edinburgh
</option>
<option value="London">
London
</option>
<option value="New York">
New York
</option>
<option value="San Francisco">
San Francisco
</option>
<option value="Tokyo">
Tokyo
</option>
</select>
</td>
</tr>
</tbody>
</table>
<button ng-click="submitTable(table)">Submit</button>
</form>
<pre>{{tableval | json}}</pre>
</body>
</html>
var app = angular.module('plunker', []);
app.controller('isrcorders', function($scope) {
$scope.submitTable = function(tablevalues) {
// $http.post('/url', tablevalues)
// .success(function(data, status) {
// })
// .error(function(data, status) {
// });
$scope.tableval = tablevalues;
console.log(tablevalues);
}
});