角1 *形式單選按鈕引用時NG-模型改變舊的內存 - 符NG檢查
我:
<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
,並且在列表更新後未選中。
我懷疑這是因爲角度窗體引用了舊內存,即使它顯示了單選按鈕的新列表。
哦....確定。儘管如此,我必須用'ng-change()'來使用它。有什麼建議麼?即使沒有ng-model和ng-change, – dman
仍然是相同的行爲。 – dman
任何方式,你可以把它放在一個笨蛋或小提琴? –