angular - 如何在 ion-select-option 中使用循环至少 100 个项目并在 .ts 文件中绑定
问题描述
我想使用任何循环在离子选择项中使用至少 18 到 100 岁的年龄列表。并在 .ts 文件中进行数据绑定
<ion-item class="my-item5" >
<ion-icon name='podium' item-right color="gray"></ion-icon>
<ion-label class="gen-col">Select age</ion-label>
<ion-select value="age" okText="Ok" cancelText="Cancel">
<ion-select-option value="18">18</ion-select-option>
<ion-select-option value="19">19</ion-select-option>
<ion-select-option value="20">20</ion-select-option>
<ion-select-option value="21">21</ion-select-option>
</ion-select>
</ion-item>
解决方案
我在 .htmnl 中找到了上述问题的解决方案
ion-select-option *ngFor="let age of ageList">{{age}}</ion-select-option>
在.ts
ageList:Array<any> = [];
this.ageList = Array.from({length:90},(v,k)=>k+18);
推荐阅读
- amazon-web-services - How reliable is AWS S3 Event Nofications on SQS?
- mysql - 选择mysql行数组中id所在的行
- list - 点火情节元素列表
- ruby-on-rails - 如何根据用户兴趣自定义排序?
- excel - VBA将实时数据值复制到另一个单元格,同一个工作表
- php - PHP stream_socket_client 和 SSL
- python - 对包含字符串和整数的列表中的元素求和,并将答案放入另一个列表 python
- javascript - Jest + react-testing-library:警告更新未包含在 act() 中
- drop-down-menu - Rundeck:根据之前的用户输入填充下拉列表
- android - 使用 Android 管理 API 策略时,Android Kiosk 模式不起作用