Here <http://plnkr.co/edit/z6UhcnorthFHFbrVZNPc?p=preview> is a simple plunker that demonstrates otherwise. You *can* use a Javascript primitive type in the ng-model and an object literal isn't required.
If I didn't understand you correctly please create a plunker and share. You may have been caught in one of the common mistakes when using primitives in AngularJS. Thanks! Mo On Monday, July 20, 2015 at 5:23:55 AM UTC-4, [email protected] wrote: > > Hey there everyone :) > > I have a very silly question but I cannot seem to find an answer > anywhere... > > Why does ng-model for a checkbox in AngularJS require a property on an > object? Why can it not just be set to a literal value on the scope? > > For example, the AngularJS documentation stipulates: > > <label>Value1: > <input type="checkbox" ng-model="checkboxModel.value1"> > </label><br/> > > > This works perfectly fine, if value1 is a property on the checkboxModel > object. But if you initialise value1 on your scope and assign the ng-model > to just value1, it no longer works. Why is that? > > Thanks :) > -- 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.
