【发布时间】:2017-03-16 06:54:58
【问题描述】:
角度 1.*
我有:
<div class="filter-column">
<div class="filter-title">Market</div>
<div class="bottom-line"></div>
<div class="overflow-container">
<input type="radio" value="all" name="marketRadio"
ng-checked="true" class="resetAll" ng-model="filter.markets"
ng-change="radioMap('market')" checked>All
<div ng-repeat="choice in markets| orderBy: 'name'">
<input type="radio" value="{{choice.name}}" name="marketRadio"
ng-change="radioMap('market')" ng-model="filter.markets" >
{{choice.description}}
</div>
</div>
在我的控制器中:
var ppvFilter = {
regions: [],
markets: [],
dealers: []
};
$scope.$watchCollection(function() {
return ppvFilter;
},
function(newValue) {
$scope.regions = newValue.regions;
$scope.markets = newValue.markets;
$scope.dealers = newValue.dealers;
});
当我使用ppvFilter.markets.length = 0; ppvFilter.markets = ppvFilter.markets.concat(['a', 'b', 'c']) 以编程方式(而不是页面刷新)刷新单选按钮列表时,单选按钮选项列表会更新,因为它应该在 gui 中。但是,ng-checked="true" 不再适用于 all,并且在列表更新后未选中。
我怀疑这是因为 Angular 表单正在引用旧内存,即使它正在显示新的单选按钮列表。
【问题讨论】:
标签: javascript angularjs