当选择另一个输入时,angularjs显示选择输入,否则显示默认值

时间:2015-09-22 12:02:22

标签: angularjs

我认为这是:

<div class="form-group">
    <label class="control-label">Order type</label>
    <select class="form-control" name="orderType" ng-model="controller.orderLine.orderType" ng-options="type.id as type.name for type in controller.orderTypes" required></select>
</div>

<div class="form-group" ng-if="controller.orderLine.orderType === 2">
    <label class="control-label">Unit of measure</label>
    <select class="form-control" name="unitOfMeasure" ng-model="controller.orderLine.unitOfMeasure" ng-options="type.id as type.name for type in controller.unitOfMeasures" required></select>
</div>

如您所见,如果 orderType 设置为2,则会显示 unitOfMeasure 选择输入。 我想要的是,当用户将 orderType 更改为2时,它会显示 unitOfMeasure 选择输入,但如果他们将其更改为其他内容,我希望 controller.orderLine.unitOfMeasure 设置为0。

有谁知道我该怎么做?

1 个答案:

答案 0 :(得分:0)

只需添加ng-change即可首先选择private class PhoneStateChangeListener extends PhoneStateListener { boolean isAnswered = false; @Override public void onCallStateChanged(int state, String incomingNumber) { switch(state){ case TelephonyManager.CALL_STATE_RINGING: isAnswered = false; break; case TelephonyManager.CALL_STATE_OFFHOOK: isAnswered=true; break; case TelephonyManager.CALL_STATE_IDLE: if(isAnswered == false) //Call hangup without answered break; } } } 在控制器中:

ng-change="onchange()"