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