0
我想将对象添加到现有列表中。这是我的代码。 在控制器:如何添加一个对象来列出angularjs中的数组
$scope.itemList = [];
$scope.itemList = function() {
return itemService.getItemList();
};
getItemList从贾森文件中读取本地没有从服务。现在我正试图将新对象添加到此列表中。 这里是我的看法:
<div>
<img src="/icon1.png" ng-click="sendNewItem()">
<input type="text" ng-model="itemtosend.itemName"/>
<input type="text" ng-model="itemtosend.itemNo"/>
</div>
在控制器:
$scope.sendNewItem = function(){
var newItem = new function(){
this.itemName = $scope.itemtosend.itemName,
this.itenNo = $scope.itemtosend.itemNo,
}
$scope.itemList = $scope.itemList.push(newItem)
}
但荫越来越推的是不是一个函数。如何将新对象添加到现有的itemList?