javascript - 禁用角度选择不起作用
嗨我在页面加载时禁用所选标签时遇到问题。我的js代码如下所示。
(function() {
angular.module('chosenExampleApp', ['localytics.directives']).controller('IndexCtrl',function($scope) {
$scope.testProp = "hello";
$scope.myPets = ['cat'];
$scope.pets = {
cat: 'Cat',
dog: 'Dog',
hamster: 'Hamster'
};
})
}).call(this);
Html正文如下所示。
<body ng-controller="IndexCtrl">
Disable <input type="radio" ng-model="testProp" name="radiotest" value="hello"/>
Enable <input type="radio" ng-model="testProp" name="radiotest" value="hello1"/>
<select
multiple
ng-model="myPets"
ng-options="value as label for (value, label) in pets"
chosen
ng-disabled="testProp=='hello'"
style="width:200px;">
</select>
</body>
由于testProp的值设置为hello,我希望在页面加载时禁用所选的。但它在页面加载时启用。一旦我选择按钮启用然后选择禁用,它的工作正常。请让我知道如何解决这个问题。
链接到Plunker是here
最佳答案:
1 个答案:
答案 0 :(得分:3)
好吧,看起来像指令中的一个错误,即:它在初始化Chosen插件之前删除了disabled
属性。这line:
stopLoading = -> element.removeClass('loading').attr('disabled', false).trigger('chosen:updated')
是问题所在。它应该是:
stopLoading = -> element.removeClass('loading').attr('disabled', attr.disabled).trigger('chosen:updated')
您可以修补源代码或等待/修复它,我打开了问题here。
以下是修正演示:http://plnkr.co/edit/gFLbMpG93TtB9xQBNTfH?p=preview
0条评论