2017-02-17 94 views
0

http://jsfiddle.net/ADukg/10211/複選框NG-模型不改變

<label class="radio-inline" style="padding-left: 0px; display: block;"> 
    <input type="checkbox" ng-model="settings_channel" ng-checked="permission.settings.channel.ADMIN" ng-disabled="permission.settings.channel.ADMIN">A 
</label> 
<label class="radio-inline" style="padding-left: 0px; display: block;"> 
    <input type="checkbox" ng-model="permission.settings.channel.READ" ng-checked="settings_channel || permission.settings.channel.ADMIN" ng-disabled="permission.settings.channel.ADMIN">B 
</label> 
<label class="radio-inline" style="padding-left: 0px; display: block;"> 
    <input type="checkbox" ng-model="permission.settings.channel.WRITE" ng-checked="settings_channel || permission.settings.channel.ADMIN" ng-disabled="permission.settings.channel.ADMIN">C 
</label> 
<label class="radio-inline" style="padding-left: 0px; display: block;"> 
    <input type="checkbox" ng-model="permission.settings.channel.ADMIN" ng-checked="settings_channel">D 
</label> 

我想要當用戶檢查A或d,B和C被禁用。

但該源不執行。

如果我選擇D我可以看到我想要的。

但是當我選擇A時,D值沒有改變,因此B和C沒有被禁用。

我該如何解決這個問題?

回答

0

試試這個:

<label class="radio-inline" style="padding-left: 0px; display: block;"> 
    <input type="checkbox" ng-model="settings_channel" ng-checked="permission.settings.channel.ADMIN" ng-disabled="permission.settings.channel.ADMIN">A 
</label> 
<label class="radio-inline" style="padding-left: 0px; display: block;"> 
    <input type="checkbox" ng-model="permission.settings.channel.READ" ng-checked="settings_channel || permission.settings.channel.ADMIN" ng-disabled="permission.settings.channel.ADMIN || settings_channel">B 
</label> 
<label class="radio-inline" style="padding-left: 0px; display: block;"> 
    <input type="checkbox" ng-model="permission.settings.channel.WRITE" ng-checked="settings_channel || permission.settings.channel.ADMIN" ng-disabled="permission.settings.channel.ADMIN || settings_channel">C 
</label> 
<label class="radio-inline" style="padding-left: 0px; display: block;"> 
    <input type="checkbox" ng-model="permission.settings.channel.ADMIN" ng-checked="settings_channel">D 
</label> 

我加入了A選項|| settings_channel等於說AD,假設settings_channel它的一個布爾值,它必須如果在一個複選框。