Angular ng-show(或 ng-if)不更新值变化

Angular ng-show (or ng-if) not updating on value change

我在 plunker 有一个简单的例子。我在一个元素上有一个 ng-show,在另一个元素上有一个 select。 select 应该切换 showing/hiding 另一个(输入)元素。最初将 select 设置为 Yes 会按预期显示其他输入元素。然后将 select 设置为 No 确实会按预期将范围值切换为 false,但不会隐藏输入元素。

我搜索了与此相关的其他帖子,我发现的帖子是关于在 ng-show 上有或没有 {{}}(我不应该有)或没有价值在 $scope 上(我这样做)。我认为这可能是一个 $scope.apply() 问题,但为什么第一个更改为 Yes 有效?同时添加 apply 仍然不会使 No(false) 起作用。我错过了什么?

TIA!

var app = angular.module('plunker', []);

app.controller('MainCtrl', function($scope) {
  $scope.conf = {};
});

您需要检查 ng-show="conf.is_ieee=='true'" 而不是 ng-show="conf.is_ieee"。检查这个 plunker。

<div class="col-md-4" ng-show="conf.is_ieee=='true'">
    <label class="form-label">IEEE Conference ID:</label>
    <input type="text" class="form-control" name="ieee-id" ng-model="conf.ieee_id"/>
  </div>

http://plnkr.co/edit/MXvuhSPB0ChJyDrvPI55?p=preview