-1
我有一个角度的动态形式。我想发送响应为json。我如何从窗体生成JSON?使JSON数组从动态表单数据角度
这里是完整的代码,我必须得到json,并将其发布到一些api。
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="dyf" ng-submit="submit()">
<form name="userFormOne" novalidate>
<table>
<tr class="form-group" ng-repeat="x in names">
<td><label>{{ x.Field }}</label>
</td><td><input type="text" class="form-control" placeholder="{{x.Comment}}" required>
</td>
</tr>
</table>{{data}}
</form>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('dyf', function($scope, $http) {
$http.get("http://localhost:5000/gu")
.then(function (response) {$scope.names = response.data;console.log(response.data);});
$scope.data ={};
});
</script>
</body>
</html>
用[NG-模型(https://docs.angularjs.org/api/ng/directive/ngModel)到输入控件绑定到数据模型。然后发送模型对象到服务器 – charlietfl
@charlietfl怎么样? – itaintme
建议你学习一些教程。 Stackoverflow不是教程服务 – charlietfl