2
  1. With default checked box is value being 1.
  2. If user can click on button like ALL or DEFAULT or NONE to select the checkboxes.
  3. If user clicks NONE, the DEFAULT checkbox should be checked and disabled; As default is always be 1.
  4. If user clicks on the button ALL or DEFAULT or any custom checks the disabled attribute should be removed and should perform normally.

Note:Need to disable the checkbox when clicks on NONE (from the controller/view);

 if(arrObj.id === 1){
    arrObj.enabled = true;
    arrObj.text = "1 [Default Value]";
    //TO DISABLE THE CHECKBOX so that it can't be unchecked
  }else{
    arrObj.enabled = false;
  }

DEMO LINK

3
  • do you want to disable all the checkboxes when user clicks none Commented Jun 7, 2014 at 4:38
  • Nope, only disable the default checkbox. Commented Jun 7, 2014 at 4:43
  • Your question is not clear. Actually what you want? please give a more explanation in your question . Commented Jun 7, 2014 at 4:46

1 Answer 1

2

add a scope variable enableBoxes and the use the ng-disable directive to disable all the checkboxes you want in this case you can use

 <input type="checkbox" ng-model="n.enabled" ng-disabled="!enableBoxes && $index==0">{{n.text}} <br/>

see example here

http://plnkr.co/edit/IMKkeyYUKzfXulhHGxpJ?p=preview

note the $index==0 for targetting only the first checkbox a more general rule can be applied if needed for targeting others

Sign up to request clarification or add additional context in comments.

2 Comments

What if the array value are dynamic and how to set a generic rule? If in case the array value is orderBy reverse or something? or has a different set as default value?
the same way you decide which is your default value you can decide which checkbox to disable you can use the same logic.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.