【问题标题】:i want to add ion-item after an ion option is selected in ion-select我想在离子选择中选择离子选项后添加离子项目
【发布时间】:2018-06-24 08:16:59
【问题描述】:

由于不同的选项有不同的信息要输入,我想问一下,在从 ion-select 中选择一个选项后,我怎样才能获得额外的 ion-item。

这些是我的代码:

<ion-item>
    <ion-label class="lbReward" color="dark" >Reward Type:  </ion-label>
    <ion-select (ionChange) = "onChange()" okText="Okay" cancelText="Dismiss" placeholder= "Select Type" formControlName = "rewardType" [ngModel] = "selectedRewardType">
        <ion-option value="priceDiscount">Total Price Discount</ion-option>
        <ion-option value="categoryDiscount">Category Price Discount</ion-option> 
        <ion-option value="freeGiftwithPrice">Sufficient Price Free Gift</ion-option>
        <ion-option value="freeGiftwithMeal">Meal with Free Gift</ion-option>
      </ion-select>
</ion-item>
<ion-item>
    <ion-label color="dark" >Discount Percentage:  </ion-label>
    <ion-input name= "discountPercent" type="text" formControlName = "discountPercent"> </ion-input>
</ion-item>

我只想在选择总价折扣后显示折扣百分比。有什么办法吗?

【问题讨论】:

    标签: ionic-framework


    【解决方案1】:

    *ngIf 语句添加到您的&lt;ion-item&gt;

    <ion-item *ngIf="selectedRewardType && selectedRewardType.length > 0">
        <ion-label color="dark" >Discount Percentage:  </ion-label>
        <ion-input name= "discountPercent" type="text" formControlName = "discountPercent"> </ion-input>
    </ion-item>
    

    【讨论】:

    • 哦,你用过[(ngModel)] = "selectedRewardType"这样的双向绑定吗?不像你写的[ngModel] = "selectedRewardType"
    猜你喜欢
    • 2021-05-15
    • 2017-10-22
    • 1970-01-01
    • 2020-12-02
    • 1970-01-01
    • 2019-12-08
    • 1970-01-01
    • 1970-01-01
    • 2020-05-29
    相关资源
    最近更新 更多