【发布时间】:2021-12-07 15:50:50
【问题描述】:
在我的项目中,我有一个年龄数组,我想根据人的年龄进行过滤,最大年龄是 65 岁,例如,如果一个人在 years 数组中是 61 岁,则只有3和4。 我怎样才能做到这一点? 这是我的stackblitz
.html
<input
matInput
formControlName="birthDate"
type="text"
class="form-control age"
placeholder="ex: 25"
required/>
<carousel
#myCarousel
height="100%"
width="120"
cellsToShow="1"
overflowCellsLimit="3"
id="age" >
<div class="carousel-cell" *ngFor="let year of years">
{{ year.year }}Years
</div>
</carousel>
.ts
years = [
{
year: 3,
value: 3,
},
{
year: 4,
value: 4,
},
];
next() {
this.personAge = (this.formGroup.get('formArray') as FormArray)
.at(0)
.get('birthDate').value;
console.log(this.personAge);
this.period = this.myCarousel.slideCounter + 3;
console.log(this.period);
}
【问题讨论】:
-
对不起 - 3 和 4 与 61 岁有什么关系...?
-
哦对不起解释不好,我的意思是如果项目的最大年龄是 65 岁,而人是 61 岁,他不能选择 5 年,bcuz 61 + 5 = 66,所以他可以选择 3 年和4 年。我解释得好吗? :D
标签: angular typescript