I would emphasize something in what fastfsfgs linked:

*New AngularJS developers often do not realize that ng-repeat, ng-switch,
ng-view and ng-include all create new child scopes, so the problem often
shows up when these directives are involved. *

When coding Angular I often just assume that all directives do this if they
are not isolate, and it saves me a lot of headaches.

On Mon, Jul 20, 2015 at 12:13 PM, Mo Moadeli (CREDACIOUS) <[email protected]
> wrote:

> No problem.  As I implied (and elaborated by fasfsfgs), you may have had a
> problem with how you were managing Javascript object references which is
> *usually* the case in these situations.
>
>
> On Monday, July 20, 2015 at 10:12:42 AM UTC-4, [email protected] wrote:
>>
>> 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.
>

-- 
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