1
我正在从数据库检索项目把它们放在目录 - 分页或ng - 重复我在这里试图传递id作为模型名称以获取密钥和名称也作为密钥我获取一个数组来创建多个输入并在控制器中检索它们,但是当我使用console.log($ scope.values)检索ng模型对象值时;它说未定义。 我如何将多个生成的输入传递给控制器的范围对象是我的问题,甚至ng-click不工作? 视图
<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);
}
您是否试过'values [x.id] [$ index]'而不是'values。{{x.id}} [$ index]'? – Julien
它的工作方式,但在控制器$ scope.values未定义 –
'ng-model'采用角度表达式作为值。我非常确定价值。{{x.id}} [$ index]'是无效的(它甚至应该抛出一个'Syntax Error',检查你的Web控制台)。 – Julien