我想提交一个包含数组数据的表单
<form ng-submit="processForm()">
<div class="item item-text-wrap item-toggle" ng-repeat="item in items | orderBy: ['id','name']">
{{item.name}}
<label class="toggle toggle-calm">
<input type="checkbox" ng-model="formData[$index].id" ng-true-value="{{item.id}}" />
<div class="track">
<div class="handle"></div>
</div>
</label>
</div>
<div class="item">
<button class="button button-block button-calm">Submit</button>
</div>
</form>
在控制器中:
.controller('ProcessCtrl', function ($scope, $http, $localStorage, $state) {
$scope.formData = [];
$scope.processForm = function () {
$http({
method: 'post',
url: 'process.php',
data: $.param($scope.formData),
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
})
.success(function (result) {
console.log(result);
})
}
})
当我提交它时,我收到此错误Cannot read property 'name' of undefined
。谁能指出我的代码有什么问题?