0

My task is: group of checkboxes must be checked(all), if checkbox-parent has been checked. Sure, using Angular. OK, what am I doing:

My parent checkbox is gettring the ng-model directive:

<input type="checkbox" ng-model="checked" ng-true-value="checked" ng-false-value="" id=""/> {{filterValue.title}}

Sub-checkboxes are getting the next:

<input type="checkbox" {{checked}} id=""/> {{subNodeValue}} 

Trying: no check in the last case, however {{checked}} calculates successfully out of the <checkbox>.

What am I doing wrong ?

UPD:

Sub-checkboxes are created by this:

<ul id="id" class="groupList">
                                  <li ng-repeat="subNodeValue in filterValue.subNodesValues">
                                     <input type="checkbox" {{checked}} id=""/> {{subNodeValue}} {{checked}}
                                  </li>
                                </ul>
1
  • 1
    if want more flexiblity when user unchecks one of the slaves try this jsfiddle.net/NE9Sf Commented Nov 6, 2013 at 12:20

2 Answers 2

1

Use the ngChecked directive instead of doing it that way (http://docs.angularjs.org/api/ng.directive:ngChecked). They have a master/slave checkbox example on there too

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

Comments

1

You can't use {{}} alone inside an element. Use ng-checked=checked instead.

Here is a working plunker: http://plnkr.co/edit/vBftwH4MwkeSiC90AltU?p=preview

Comments

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.