我正在从db检索项目--把它们放在dir-分页或ng--重复我在这里输入的id作为模型名来获得键和名称,就像我获取数组来创建许多输入并在控制器中检索它们一样,但是当我用console.log($scope.values)检索ng模型对象值时,它说没有定义。如何将多个生成的输入传递给作用域对象中的控制器是我的问题,即使是ng-单击“不工作”??视图。
<form angular-validator-submit="submitForm()"
name="submit-form" class="form-horizontal" novalidate
angular-validator>
<table>
<thead>
<tr>
<th>S.No</th>
<th>id</th>
<th>Name</th>
</tr>
</thead>
<tbody>
<tr dir-paginate="x in items| itemsPerPage: pageSize" current-page="currentPage">
<td><input type="text" name="id" ng-model="values.{{x.id}}[$index]"></td>
<td><input type="text" name="test" ng-model="values.{{x.name}}[$index]"></td>
</tr>
</tbody>
</table>
<button type="submit" class="btn btn-primary">Save</button>
</form>
$scope.submitform = function(){
console.log($scope.values);
}发布于 2017-05-04 09:22:19
ng-model="values[x.id]"将按照注释中的建议进行工作并定义$scope.values = [];。
https://stackoverflow.com/questions/43764028
复制相似问题