The only way I've been able to get it to work is to have an ngScope assigned to the master checkbox and then update that scope variable as a side effect of the ngChecked call. This doesn't really seem kosher nor does it seem like it should be necessary (I expected Angular to handle this). Unfortunately, since I want to keep all of the logic in the master checkbox, this was the cleanest way.
Here's an update to your original fiddle (I use ngChange to update the child states rather than ngClick): http://jsfiddle.net/thr3ee/83cvu/ On Saturday, September 22, 2012 12:39:32 PM UTC-7, Pete Bacon Darwin wrote: > > Actually this doesn't quite work as I wanted... > > On 22 September 2012 20:37, Peter Bacon Darwin > <[email protected]<javascript:> > > wrote: > >> I would simply implement this in a different way: >> http://jsfiddle.net/vdapp/ >> >> >> On 20 September 2012 05:13, floydsoft <[email protected] <javascript:>>wrote: >> >>> Hi folks, >>> >>> Current ng-checked is an one-way binding, and ng-model is a two-way >>> binding, so we can assign ng-checked another model to effect the input, but >>> input not effect another model. >>> >>> This design can implement master-slave relationship to form group check, >>> but ng-checked only effects input, it does't syncs ng-model, it's weird. >>> >>> Consider http://jsfiddle.net/nAjXd/ , slave's model will not change >>> even input is checked by ng-checked. >>> >>> Since ng-model is two-way binding, input should honor this contract, so >>> after ng-checked checks on input, it should checks ng-model too. >>> >>> It may look likeļ¼ >>> >>> "master's model" (by ng-checked) --> input <--> "slave's >>> model(ng-model)" >>> >>> Current version will break when ng-checked checks input, ng-model will >>> not be sync. >>> >>> I've opened a PR https://github.com/angular/angular.js/pull/1057 , but >>> Angular team didn't think it's make sense. >>> >>> Do I make any mistake or other better solutions on this issue? >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "AngularJS" group. >>> To post to this group, send email to [email protected]<javascript:> >>> . >>> To unsubscribe from this group, send email to >>> [email protected] <javascript:>. >>> Visit this group at http://groups.google.com/group/angular?hl=en. >>> >>> >>> >> >> > -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
