基本上我有一系列通过ng-repeat显示的区域:
<div ng-repeat="district in districts | filter:search:startsWith" class="district">
<h4 class="district-name">{{ district.district }}</h4>
这是一个数组:
var districtsArrayNotSorted = [
{district:'Alpha district',link:'#',cities:['Zumbida','Kappa','Numba']},
{district:'Beta district',link:'#',cities:['Jordda','Mamba','Nemessis']},
{district:'Berta district',link:'#',cities:['Rumba','Samba','Chacha']},
{district:'Gamma district',link:'#',cities:['Zapdos','Pikachu']}
];
var districtsArray = districtsArrayNotSorted.sort(function(a,b){
var distrA = a.district.toLowerCase(), distrB = b.district.toLowerCase();
if ( distrA > distrB) return 1
});
区阵列中有另一个阵列(每个区的城市)。
我试图在.district
区块中显示城市(嵌套在嵌套数组中)。
这是DEMO
你有什么想法可以到达那些城市来展示它们吗?
答案 0 :(得分:1)
认为你可以这样做:
<div class="container">
<input id="q" type="text" ng-model="search " />
<div ng-repeat="district in districts | filter:search:startsWith" class="district">
<h4 class="district-name">{{ district.district }}</h4>
<a href="{{ district.link }}">Some info</a>
<ul class="district-cities">
<li ng-repeat="city in district.cities">
{{city}}
</li>
</ul>
</div>
</div>
plunkr here