【发布时间】:2020-01-14 00:38:48
【问题描述】:
我想获取我单击的特定年份的月份线,以便能够将其链接到更多数据集。
<div class="list-float-right">
<ul >
<li *ngFor="let years of yearData">
<a href=#{{years.year}}>{{years.year}}</a>
</li>
</ul>
</div>
<hr>
<div class="list-float-right">
<ul>
<div *ngFor="let years of yearData">
<li *ngFor="let months of years.monthData">
{{months.month}}
</li>
<br>
</div>
</ul>
</div>
<div *ngFor="let years of yearData">
<div id={{years.year}}>
{{years.year}}
<br>
The color of animals <br>is by no means <br>a matter of chance;
<br>it depends on many considerations,
<br>but in the majority of cases tends to protect the animal
from danger by rendering it less conspicuous.
<hr>
</div>
yearData = [{
year:2019,
monthData: [
{ month : "jan"},
{ month : "july"}
]
},{
year:2018,
monthData: [
{ month : "march"},
{ month : "april"}
]
},{
year:2017,
monthData: [
{ month : "march"},
{ month : "dec"}
]
},{
year:2016,
monthData: [
{ month : "march"},
{ month : "feb"}
]
},{
year:2015,
monthData: [
{ month : "jan"},
{ month : "may"}
]
}
];
每年和每个月的数据都相互关联。因此,如果我单击 2019 年,然后选择在给定年份可用的年份。
输出格式
年栏
给定年份可用的月份栏。
如果没有选择年份,它会自动指向最近年份的月份。就像在给定的 json 中一样,它应该给出 2019 年的月份。
预期输出
2019 2018 2017 2016 2015 // 如果我点击 2018 它将显示在下一行
march april // & 如果我没有点击任何年份,它将给出 2019 年。
【问题讨论】:
-
你试过解决方案了吗?