【发布时间】:2015-12-14 08:24:57
【问题描述】:
我正在做一个网络应用程序。
我有一个动态表格。首先,您选择 PRODUCT,然后选择 LOT。选择中的项目列表由 json 获取。现在的问题是我想添加创建新项目以添加到<select> LOT 的可能性。
所以,首先我尝试使用以下代码在 LOT 列中添加该字段:
$scope.addLot = function(id,val,lotId) {
// console.log(id);
var inWhichProduct = id;
var newArray = { "value": val, "id": lotId };
//console.log($scope.items)
angular.forEach($scope.items,function(v,i){
if($scope.items[i].id == id )
{
$scope.items[i].lots.push(newArray);
console.log($scope.items[i].lots);
}
});
};
它可以工作(here 就是一个例子)。但我想要做的是在模式窗口中移动这些字段。我试过这个,但它不起作用(here 是另一个例子)。为什么?也许正确的方法是在json中添加item,然后刷新LOT,但是如何在json中添加item呢?
【问题讨论】:
标签: javascript angularjs json modal-dialog ngtable