我的形式select和ng-options工作完全罚款AngularJS 1.2.26,处处显示着默认的选择,如果toy.toy_container_name是在现有containers阵列.但是,升级到1.3.0后,选择下拉列表不再显示默认选择(Chrome,FF和Safari中的行为相同,因此不会出现浏览器问题).我的Selenium测试抓住了这个,现在我很困惑为什么.1.3.0似乎没有任何可能导致此问题的弃用或明显变化(从1.2.6开始).此外,
<select class="form-control" ng-model="toy.toy_container_name" ng-options="c.container_name as c.container_name for c in containers" required>
<option value="">- Pick Container -</option>
</select>
Run Code Online (Sandbox Code Playgroud)
进一步使这种混淆是对源的检查显示正确的选择; 但是,下拉选择框不显示所选的默认值:
Chrome Elements检查器:
<option value="" class="">- Pick Container -</option>
<option value="0">A-BIN</option>
<option value="1" selected="selected">B-BIN</option>
<option value="2">F-BIN</option>
<option value="3">G-BIN</option>
Run Code Online (Sandbox Code Playgroud)
编辑:我发现了这个问题:
为什么要移动'$ scope.toy = toy;' 在获取容器之后,在新的Angular 1.3.0中有所作为吗?
$http({method: 'GET', url:'/toys/'+$stateParams.id}).success(function(toy, status, headers, config) {
$scope.original = angular.copy(toy);
//$scope.toy = toy; // WORKED in AngularJS 1.2.26 but not 1.3.0
$http({method: 'GET', url:'/containers'}).success(function(containers, status, headers, config) {
$scope.toy = toy; // moved from where previously commented; NOW works with AngularJS 1.3.0
$scope.containers = containers;
}).error(errorMessage.onError);
}).error(errorMessage.onError);
Run Code Online (Sandbox Code Playgroud)
该问题是 1.3x 分支中的一个已知错误。请参阅此处: https: //github.com/angular/angular.js/issues/11835
选择控制器没有意识到选项已更改 - 必须手动强制渲染。
| 归档时间: |
|
| 查看次数: |
2321 次 |
| 最近记录: |