...or better yet declare vars inside an object to prevent the dreaded
(Halloween voice) * "scope overlap!"*

scope.myContainer = {};

scope.myContainer.myScopeSafeVar = 0;


On Tue, Jul 1, 2014 at 8:10 AM, Jonathan Matthew Beck <[email protected]>
wrote:

> Ok I think I've got it, *and please correct me if I am wrong.*  (No,
> really, I want to learn this stuff).
>
> The automagical things Angular does with variables and scopes is throwing
> me a bit, coming from C# where I "own" the variables.  In certain context's
> Angular "owns" the variables and that's why I get errors.
>
> What I think it boils down to is: If I want to create or add a variable to
> a scope, *don't do it in the directive's html tag or in the scope: {}
> declaration.*  Just *declare *the variable in the code as:
>
> scope.myVar = 0;     - this is my var, and yes it is in the scope.
>
> not
>
> <mydir myVar="0"></myDir>   --*  Angular says, "nono!! That's MY var
> now."*
>
> or
>
> return {
>   restrict:'E',
>   scope: {
>      myVar: "0"              --*  not your var anymore, Toto!*
>   },
> ...
> }
>
>
> On Mon, Jun 30, 2014 at 3:23 PM, Jonathan Matthew Beck <[email protected]>
> wrote:
>
>> Here is the plunker: http://plnkr.co/edit/4nPX4Z
>>
>> The json directive will send a message to the jsonEdit directive, which
>> will load a template with a new model displayed.
>>
>> I don't know why it isn't working.  Once I get the message there I keep
>> encountering this error: Expression 'undefined' used with directive
>> 'jsonEdit' is non-assignable!
>>
>>
>>  --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "AngularJS" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/angular/pgk1I8T-5lc/unsubscribe.
>> To unsubscribe from this group and all its topics, 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