异步加载选项时,选择指令不选择选项 [英] Select directive not selecting option when options are loaded asynchronously
问题描述
我有一个 指令,它的选项是异步加载的.
ng-model
属性指向的变量在加载选项之前就存在.但是,加载选项后,未选择正确的选项.相反,选择变为空白.我创建了一个 plunk 来演示这种行为:http://plnkr.co/edit/KNunC6.
I have a <select>
directive whose options are loaded asynchronously. The variable that the ng-model
attribute points to exists prior to the options being loaded. However, after the options are loaded the correct option is not selected. Instead, the select becomes blank. I've created a plunk to demonstrate this behaviour: http://plnkr.co/edit/KNunC6.
推荐答案
https://github.com/angular/angular.js/issues/9714#ref-pullrequest-53337829
似乎这是一个角度核心错误.使用 ng-repeat
和 ng-checked
我猜你会更成功.
seems like this is an angular core bug. you'd be more successful using ng-repeat
and ng-checked
I guess.
这篇关于异步加载选项时,选择指令不选择选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!