angular - 具有 i 到 j 值的离子选择
问题描述
我想使用 ionic4 创建一个离子选择菜单,用户可以在其中选择 20 到 220 之间的值,但无需手动编写 20、21、22 等...
我已经尝试实现这篇文章Tersest way 的方法,以在 JavaScript 中从 1..20 创建一个整数数组
但我不知道如何使用打字稿将此 javascript 代码转换为我的 ionic4 应用程序...
谢谢您的帮助。
解决方案
What you can do is
First, create an array which is going to contain the numbers
numbers = [];
Then in your ngOnInit function create a for loop to add the numbers
ngOnInit() { for (let i = 20; i <= 220; i++) { this.numbers.push(i); } }
then use the array in your HTML file like below
<ion-select> <ion-select-option *ngFor="let num of numbers">{{num}}</ion-select-option> </ion-select>
If you could share your existing codebase where you want this feature to be implemented i can show you specifically where to add the codes!
推荐阅读
- c# - 在 ASP:GridView 中插入特定元素
- ios - 我正在尝试使用协议和委托模式,它将我的数组中的数据传递回父视图控制器
- python - 同一网络上的 docker 容器(来自 compose)看不到对方
- python - 确定组的共同值
- r - 基于栅格层网格单元数差异的子集 R rasterstack
- c++ - 参考向量的函数的原型是什么
- reactjs - 在 TypeScript 中检查类型中的类型
- debugging - 为什么我的 Symfony 5 formbuilder 中所需的属性没有更改为 false?
- javascript - 是否有使用 WebSockets 发送消息的事件?(JS)
- docker - Argo:可变数量的输出工件