Hi Mo.

Many thanks for this, I see indeed according to your Plunker it DOES work.

I had an app where I couldn't get it to work at the time with a primitive 
type, I changed it to an object literal and it worked. I shrugged it off 
and just continued with the app but I was kinda curious as to why that 
happened.

The issue must have been somewhere else!

Thank you for the info :)

On Monday, 20 July 2015 16:09:01 UTC+2, Mo Moadeli (CREDACIOUS) wrote:
>
> 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.

Reply via email to