Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
angularjs在选择其他输入时显示选择输入,否则为默认值_Angularjs - Fatal编程技术网

angularjs在选择其他输入时显示选择输入,否则为默认值

angularjs在选择其他输入时显示选择输入,否则为默认值,angularjs,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

我认为:

<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>

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


有人知道我怎么做吗?

只需将ng change添加到first select
ng change=“onchange()”
在控制器中:

$scope.onchange = function() {
    if ($scope.controller.orderLine.orderType != 2) {
        $scope.controller.orderLine.unitOfMeasure = 0;
    }
}