I have an array with x items. I need to copy this items and add a few more, but when I show the items in the ng-repeat I copy the firsts again.
我有一个带x项的数组。我需要复制这些项目并添加一些,但当我在ng-repeat中显示项目时,我再次复制第一。
How can I delete the items and put the new in real time? I tried using
如何删除项目并实时新建?我试过用
delete $scope.items
$scope.items = []
But It not works.
但它不起作用。
It seems very basic question but I can't find a solution :(
这似乎是非常基本的问题,但我找不到解决方案:(
EDIT
In the function when I add new items
在我添加新项目的功能中
$scope.order = function(auxItems){
var auxTotal = $scope.items;
auxItems.map(function(bono){
auxTotal.push(bono);
});
When I do some some stuff to add the items definitely I return an array.
当我做一些东西来添加项目肯定我返回一个数组。
var bonosOrdenados = $scope.ordena(auxBonos);
bonosOrdenados.map(function(elemento){
elemento.map(function(bono){
$scope.items.push(bono);
})
});
And of course the items are duplicated because I don't knot how to control it.
当然,这些项目是重复的,因为我不知道如何控制它。
1 个解决方案
#1
0
Try in your script:
试试你的剧本:
$scope.clear = function () {
items.length = 0;
}
And in your HTML you call the clear-function with ng-click or somthing else.
在HTML中,您可以通过ng-click或其他方式调用clear-function。
#1
0
Try in your script:
试试你的剧本:
$scope.clear = function () {
items.length = 0;
}
And in your HTML you call the clear-function with ng-click or somthing else.
在HTML中,您可以通过ng-click或其他方式调用clear-function。