在页面加载时,我有一个 Angularjs controller.js,它从 ajax 响应设置范围模型:
services.InitializePage().then(function (response) {
$scope.DataModel = response.data;
然后几行后模型被改变:
$scope.DataModel.SameAsShipToAddress = false;
但是,视图上的单选按钮不会使用新值更新并且保持未选中状态:
<input type="radio" name="SameAsShipToAddress" ng-model="DataModel.SameAsShipToAddress" ng-click="setSameAsShipAddress(true)" value="true" />
<input type="radio" name="SameAsShipToAddress" ng-model="DataModel.SameAsShipToAddress" ng-click="setSameAsShipAddress(false)" value="false" />
注意:如果我在 InitializePage 方法之外设置模型,则会更新 UI 单选按钮。(我用断点验证了 services.InitializePage().then(function (response) 块被击中)