Açısal görünümde bir modele bağlanan seçme elemanım var. Formu klavyeyle doldururken, ikinci seçenekte oku aşağı oklarsanız, modelin hala ilk değeri temsil ettiğini fark ettim. Bu sadece formu doldurmak için klavyeyi kullanırken olur. Set upÖğeyi açısal olarak güncellemeden seçin Model ikinci bir seçimdeValue
1.4.3 açısal kullanarak, oldukça basittir:
var app = angular.module('app', []);
app.controller('myController', function() {
var vm = this;
vm.options = [{
Id: 1,
Value: 'A'
}, {
Id: 2,
Value: 'B'
}, {
Id: 3,
Value: 'C'
}]
});
<script src="https://code.angularjs.org/1.4.3/angular.js"></script>
<body ng-app="app">
<div ng-controller="myController as ctrl">
<p>
Model is not updated on second down button push. Repro:
<ol>
<li>Tab to select element</li>
<li>Hit down and notice the optionId updated to 1</li>
<li>Hit down again and notice that the displayed value changes to B, but optionId stays as 1</li>
<li>Hit down again and notice that the displayed value changes to C, and optionId changes to 3</li>
<li>Hit up and notice that displayed value changes to B, and optionId changes to 2</li>
</ol>
Why doesn't the optionId = 2 on the initial selection of B
</p>
<select id="mySelect" ng-options="item.Id as item.Value for item in ctrl.options" ng-model="ctrl.optionId" style="width:200px">
</select>
<div><strong>optionId: {{ctrl.optionId}}</strong>
</div>
</div>
</body>
neden değil ikinci aşağı ok tuşuna basın yenilenen modeli?
Güncelleme İşte Burada Matt önerdiği geçici çözümü uygulayan bir modified plunker var davranışı sergileyen bir plunker, http://plnkr.co/edit/Hiu67NTR3Gpk9jByZtQD?p=info
2 Güncelleme bu. Bu geçici çözüm, Chrome, Firefox ve Internet Explorer
Up. Tuhaf. Umarım çözdüğün şeyi merak ederdim. Şüphelenmek bir hatadır – scniro
Gerçekten çok garip. Bir sorun açtım https://github.com/angular/angular.js/issues/12562 –
Hangi tarayıcıyı kullanıyorsunuz? Sorunu Chrome'da görüyorum, ancak IE11'de (Win7'de), hepsi iyi görünüyor. Tarayıcıda daha fazla açılan bir sorun olup olmadığını merak ediyorum. –