gpt4 book ai didi

javascript - Angular JS NG-子数组中的重复

转载 作者:行者123 更新时间:2023-11-28 19:10:30 25 4
gpt4 key购买 nike

我需要对子数组(数组的元素内部)执行 ng-repeat。这是数据;

{familyName:'Vodka', familyCode:'1', hasPremium: '1', families: [
{ subFamilyName: 'Best', products: [
{ title: 'Grey goose 70 cl', price: '400', cant: '0', premium: '1' },
{ title: 'Grey goose 1,5l', price: '875', cant: '0', premium: '0' }
]},
{ subFamilyName: 'Poor', products: [
{ title: 'Grey goose 10 cl', price: '40', cant: '0', premium: '0' },
{ title: 'Grey goose 17,5l', price: '85', cant: '0', premium: '0' }
]}
]},
{familyName:'Rum', familyCode:'1', hasPremium: '1', families: [
{ subFamilyName: 'Best', products: [
{ title: 'Grey goose 70 cl', price: '400', cant: '0', premium: '1' },
{ title: 'Grey goose 1,5l', price: '875', cant: '0', premium: '0' }
]},
{ subFamilyName: 'Poor', products: [
{ title: 'Grey goose 10 cl', price: '40', cant: '0', premium: '0' },
{ title: 'Grey goose 17,5l', price: '85', cant: '0', premium: '0' }
]}
]

完美。我的 $scope 中有一个名为 selectedFamily 的变量,它保存出于导航目的而选择的家庭代码。现在,在 a 中,我需要打印所选系列的子系列(在 selectedFamily var 中编码)以及每个子系列的产品。

我在想如何过滤并执行 ng-repeat。

最佳答案

这是适合您的解决方案

<li ng-repeat="item in items">
<input type="text" ng-model="item.familyName" />
<input type="text" ng-model="item.familyCode" />
<ul>
<li ng-repeat="subItem in item.families">{{subItem.subFamilyName}}
<div ng-repeat="subSubItem in subItem.products">
<input type="text" ng-model="subSubItem.title" />
<input type="text" ng-model="subSubItem.price" />
</div>
</li>
</ul>
</li>

你可以看看这个 fiddle http://jsfiddle.net/1ncubt8v/

关于javascript - Angular JS NG-子数组中的重复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30802877/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com