Ionic if else语句显示和显示数据 [英] Ionic if else statement to display and show data

查看:1598
本文介绍了Ionic if else语句显示和显示数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用离子框架制作应用程序。我想像在php中那样做一个if / else语句。

I am using the ionic framework to make an app. I want to do an if/else statement like I would in php.

基本上,如果用户没有从下面的代码中选择一个帐户,那么后面的标签就不能显示。

Basically if the user does not select an account from the code below then the label after it must not show.

 <label class="item item-input item-select">
                    <div class="input-label">
                        Choose your account
                    </div>
                    <select ng-model="vm.paymentPlanData.matter" ng-change="vm.newAccount()">
                        <option ng-repeat="account in vm.accounts" value="{{account.matterno}}">{{account.company}}</option>
                    </select>
                </label>

但如果他们选择了一个帐户,那么必须显示

But if they then have selected an account then this must show

<label class=" item-input item-stacked-label" ng-if="{{account.company !== null}}">
                <div class="row">
                    <span class="input-label col">Amount</span>
                    <span class="col" style="text-align: right">R{{vm.paymentPlanData.amount}}</span>
                </div>
                <div class="range range-energized">
                    <span>R{{vm.account.minPaymentPlanAmount}}</span>
                    <input type="range" step='5' name="volume" min='{{vm.account.minPaymentPlanAmount}}'  max='{{vm.account.maxPaymentPlanAmount}}'  ng-model="vm.paymentPlanData.amount">
                    <span>R{{vm.account.maxPaymentPlanAmount}}</span>
                </div>
            </label>

我尝试使用ng-if like this

I tried using an ng-if like this

<label class=" item-input item-stacked-label" ng-if="{{account.company}} !== null">

但这不起作用。是ng-if正确的方法呢?如果是这样,还有更多我遗漏的东西?

But this doesnt work. is the ng-if the right way to go about this? and if so is there something more that I am missing?

推荐答案

如果你想让标签仅在从中选择某些东西时显示选择元素,然后在标签的ng-if条件中使用select元素ng-model变量。这样的东西

If you want the label to show only when something is selected from your select element, then use the select element ng-model variable in the ng-if condition of your label. Something like this

<label class=" item-input item-stacked-label" ng-if="vm.paymentPlanData.matter">

编辑:这是样本插件这个在角度js工作

here is a sample plunk for this working in angular js

这篇关于Ionic if else语句显示和显示数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆