找到当前数组项的兄弟姐妹 [英] Find sibling of current array item
本文介绍了找到当前数组项的兄弟姐妹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这目前列出了阵列的所有事件。我只想显示父数组中的当前项目相关联的阵列。
EG:而不是列出第一个位置,第二是地段,第三位置。我希望它只列出第一个位置的第一位置,第二个位置为第二位置,等我缺少什么?
http://plnkr.co/edit/ilgOZzIy2axSi5Iy85C7
VAR应用= angular.module('应用',[]);App.controller('locationAccordionCtrl',函数($范围){ $ scope.locations = [
{
网站名:第一位置,
locationsList:[第一位置1','第一位置2','第一位置3']
},
{
网站名:第二位置
locationsList:[第二位置1','第二位置2','第二位置3']
},
{
网站名:三位置
locationsList:[第三位置1','第三位置2','第三位置3']
}
];
});
HTML
< DIV NG控制器=locationAccordionCtrl>
< DIV NG重复=位置,位置> {{location.siteName}} < DIV NG重复=位置,位置>
< UL>
<李NG重复=在location.locationsList轨道listOfLocations由$指数>
{{listOfLocations}}
< /李>
< / UL>
< / DIV> < / DIV><! - /行 - >
< / DIV>
解决方案
您应该改变:
< DIV NG重复=位置,位置>
< UL>
<李NG重复=在location.locationsList轨道listOfLocations由$指数>
{{listOfLocations}}
< /李>
< / UL>
< / DIV>
要这样:
< UL>
<李NG重复=在location.locationsList轨道listOfLocations由$指数>
{{listOfLocations}}
< /李>
< / UL>
This currently lists out all occurrences of the array. I only want to show the array associated for the current item in the parent array.
EG: Instead of listing First Location, Second Location, Third Location. I want it to only list First Location for the First Location, Second Location for the Second Location, etc. What am I missing?
http://plnkr.co/edit/ilgOZzIy2axSi5Iy85C7
var App = angular.module('App', []);
App.controller('locationAccordionCtrl', function ($scope) {
$scope.locations = [
{
"siteName":"First Location",
"locationsList":['First Location 1', 'First Location 2', 'First Location 3']
},
{
"siteName":"Second Location",
"locationsList":['Second Location 1', 'Second Location 2', 'Second Location 3']
},
{
"siteName":"Third Location",
"locationsList":['Third Location 1', 'Third Location 2', 'Third Location 3']
}
];
});
HTML:
<div ng-controller="locationAccordionCtrl">
<div ng-repeat="location in locations">
{{location.siteName}}
<div ng-repeat="location in locations">
<ul>
<li ng-repeat="listOfLocations in location.locationsList track by $index">
{{listOfLocations}}
</li>
</ul>
</div>
</div><!-- /row -->
</div>
解决方案
You should change:
<div ng-repeat="location in locations">
<ul>
<li ng-repeat="listOfLocations in location.locationsList track by $index">
{{listOfLocations}}
</li>
</ul>
</div>
To this:
<ul>
<li ng-repeat="listOfLocations in location.locationsList track by $index">
{{listOfLocations}}
</li>
</ul>
这篇关于找到当前数组项的兄弟姐妹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文