Angularjs ';中继器中不允许重复。按$index跟踪不起作用

Angularjs ';中继器中不允许重复。按$index跟踪不起作用,angularjs,Angularjs,我对angularjs还是个新手。我有这个问题。我在几个问题中发现了这一点,但没有人对我有好处,因为我使用了上面提到的track by$index,但没有和我一起工作。有人能帮我吗 html: 图像 产品说明 排名第一 价格 全部的 {{product.nameProduct} 产品代码:{{Product.numserie}} {{product.price}} {{product.price*quantite[product.id]} 去除 这是我的控制器,我在这里填写我的列表 for

我对angularjs还是个新手。我有这个问题。我在几个问题中发现了这一点,但没有人对我有好处,因为我使用了上面提到的track by$index,但没有和我一起工作。有人能帮我吗

html:


图像
产品说明
排名第一
价格
全部的
{{product.nameProduct}
产品代码:{{Product.numserie}}

{{product.price}} {{product.price*quantite[product.id]} 去除
这是我的控制器,我在这里填写我的列表

for (var i =0; i< $scope.chosenProducts.length; i++)
                            {
                            console.log(" lllll "+$scope.chosenProducts[i].quantite +"  "+$scope.quantite[$scope.chosenProducts[i].id]);
                            for (var j=0; j<$scope.quantite[$scope.chosenProducts[i].id]; j++)
                                {

                               $scope.chosenPdtByQte.push($scope.chosenProducts[i]);

                            }
                            }
for(变量i=0;i<$scope.chosenProducts.length;i++)
{
console.log(“llllll”+$scope.chosenProducts[i].quantite++++$scope.quantite[$scope.chosenProducts[i].id]);

对于(var j=0;j尝试使用
track by product.id

<tr class="cake-bottom" 
 data-ng-repeat="product in chosenPdtByQte track by product.id">
......
</tr>

......

我真的不知道为什么您使用这种方式创建了一个列表,并尝试对其应用ng repeat,但我想下面的代码运行良好,没有重复问题

angular.module(“myApp”,[])
.controller(“myCtrl”,函数($scope){
$scope.chosenProducts=[{
“id”:1,
“nameProduct”:“testA”,
“numserie”:“xx ff gg ss”,
“价格”:20
}, {
“id”:2,
“nameProduct”:“testB”,
“numserie”:“yy ee gg ss”,
“价格”:30
}, {
“id”:3,
“nameProduct”:“testC”,
“numserie”:“xx ss gg ss”,
“价格”:40
}, {
“id”:4,
“nameProduct”:“testD”,
“numserie”:“xx ff ff ss”,
“价格”:50
}, {
“id”:5,
“nameProduct”:“testE”,
“numserie”:“xx-ff-11-ss”,
“价格”:60
}, {
“id”:6,
“nameProduct”:“testF”,
“numserie”:“xx ff dd ss”,
“价格”:70
}];
$scope.quantite=[
4, 5, 6, 7, 8, 9
];
$scope.chosenPdtByQte=[];
对于(变量i=0;i<$scope.chosenProducts.length;i++){
对于(var j=0;j<$scope.quantite[$scope.chosenProducts[i].id];j++){
$scope.chosenPdtByQte.push($scope.chosenProducts[i]);
}
}
log($scope.chosenPdtByQte);
});

图像
产品说明
排名第一
价格
全部的
{{product.nameProduct}
产品代码:{{Product.numserie}}

{{product.price}} {{product.price*quantite[product.id]} 去除
你确定是
ng repeat
导致了问题吗?
ng options
将在中继器中抛出相同的
重复项是不允许的
错误,因此也许你应该再次检查
numSeries
是否唯一。我确定,因为我在使用ng options之前就遇到了这个问题。你能提供一个小提琴或小提琴吗类似于查看发生了什么?什么意思是按$index跟踪不起作用?尝试时结果如何?总是有相同的问题:/
<tr class="cake-bottom" 
 data-ng-repeat="product in chosenPdtByQte track by product.id">
......
</tr>