首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >要计算的ion select和ion datetime中的ion Pass值

要计算的ion select和ion datetime中的ion Pass值
EN

Stack Overflow用户
提问于 2019-10-23 15:28:23
回答 1查看 301关注 0票数 0

UI for my indexicator

以下是我的项目的UI

大家好,我想问一下,我是否可以根据位置和年份传递值?这是我在ionic中的第一个项目,这是一个简单的计算器,但计算量取决于地点和年份。

例如,我将利率设置为10,然后在前面的索引中,我选择了位置英国,利率将除以2,然后我将2011年,它将再次除以2。

之后,对于新的索引,我将重复输入,但现在它将根据所选的位置和年份进行倍增。

这是我的利率,位置和年份的.html。我还包括了一个按钮,它将在离子输入占位符处显示总金额。

我不知道要在.ts中编写什么代码

代码语言:javascript
复制
 <ion-list>


<ion-item> 
  <ion-label stacked>Rate</ion-label>
<ion-input type="text" text-right id="input" ></ion-input>
</ion-item>  

 <br>
 <br>
  <ion-list-header>Previous Index</ion-list-header>

 <ion-list>
  <ion-item>
   <ion-label>Location</ion-label>
  <ion-select value="50" okText="Okay" cancelText="Dismiss">
  <ion-select-option value="50">UK</ion-select-option>
  <ion-select-option value="70">US</ion-select-option>
  <ion-select-option value="30">Canada</ion-select-option>

   </ion-select>
 </ion-item>

</ion-list>
  <ion-item>
    <ion-label>Year</ion-label>
     <ion-datetime [pickerOptions]="customPickerOptions" placeholder="Select One" 
   displayFormat="YYYY" min="2011" max="2019"></ion-datetime>
    </ion-item>

 <ion-button type ="submit">Total</ion-button>


  <div class="window"></div>
  <div class="input"><span>
      <ion-input type="text" placeholder="0" name="display">
      </ion-input>
EN

回答 1

Stack Overflow用户

发布于 2019-10-23 17:04:59

你的html应该是这样的,

代码语言:javascript
复制
 <ion-item>
    <ion-label>Location</ion-label>
    <ion-select (change)="onSelectionChanges($event)" [(ngModel)]="currentSelection" okText="Okay" cancelText="Dismiss">
          <ion-select-option selected="true" value="50">UK</ion-select-option>
          <ion-select-option value="70">US</ion-select-option>
          <ion-select-option value="30">Canada</ion-select-option>
    </ion-select>
 </ion-item>

您还可以将一些onChange事件绑定到ion-select。并触发一些方法,例如: onSelectionChanges()

代码语言:javascript
复制
export class Example{
    currentSelection = '50';

    onSelectionChanges(event: any) {
        // Your logic to apply when selection happens, goes here
        //You can also get the value in the variable currentSelection
        console.log(this.currentSelection);
        //another way is to access the changed value from event
        console.log(event.target.value);
    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58517631

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档