0
我已經編寫了一個代碼來從輸入中傳遞值並將其推入數組中。然後我試圖使用ng-repeat在表中顯示列表的值。但我無法顯示數組中的值。我無法在dispList中顯示我的代碼。通過在數組中循環顯示ng-repeat的值
請讓我知道如何顯示dispList中的數組對象。
我已經編寫了一個代碼來從輸入中傳遞值並將其推入數組中。然後我試圖使用ng-repeat在表中顯示列表的值。但我無法顯示數組中的值。我無法在dispList中顯示我的代碼。通過在數組中循環顯示ng-repeat的值
請讓我知道如何顯示dispList中的數組對象。
由於我缺少您的代碼段,我想我只想創建一些附加和列表的邏輯:
// JavaScript的
$scope.list = [];
$scope.addItem = function(item) {
$scope.list.push({ name : item.name, price : item.price })
}
//視圖
<div>
<input ng-model="item.name" placeholder="name"></input>
<input ng-model="item.price" placeholder="price"></input>
<button ng-click="addItem(item)" >Add</button>
</div>
<div ng-repeat="it in list">
{{ it.name }} {{ it.price }}
</div>
顯示你的代碼。 –
沒有代碼.. –