--
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 angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.
Your problem seems to be related to how inheritance in JavaScript works.
'x' has 'a' property.
'y' inherits from 'x'.
x.a = 5;
y.a now is equal to 5.
y.a = 8;
y does not inherit 'a' from 'x' any more.
x.a is still equal to 5.
y.a is equal to 8.
Try this:
x.a = {value: 5};
y.a.value = 8;
What's the x.a.value now?
Ha!
Regards,
Witold Szczerba
---
Sent from my mobile phone.
It seems that the ng-if directive has its own isolated scope. Is that intended ?
=
or=attr
- set up bi-directional binding between a local scope property and the parent scope property of name defined via the value of theattr
attribute. If noattr
name is specified then the attribute name is assumed to be the same as the local name. Given<widget my-attr="parentModel">
and widget definition ofscope: { localModel:'=myAttr' }
, then widget scope propertylocalModel
will reflect the value ofparentModel
on the parent scope. Any changes toparentModel
will be reflected inlocalModel
and any changes inlocalModel
will reflect inparentModel
.
"Thomas Fétiveau" <thomas.fet...@gmail.com> wrote:
> What Witold has written is clearer to me now, is: when a scope is a child of another scope, it 'inherits' its properties. If those properties are objects, it actually inherits references to those objects so that the following happens :
>
> a.x = { 'value': true };
> // a extends b
> b.x.value = false;
> // now a.x.value is now false too
>
> But as soon as inherited properties are primitives, they won't get updated in the parent scope:
>
> a.y = true;
> // a extends b
> b.y = false;
> // a.y is still true, sad :( !
It is not about primitives vs objects as properties. It is about overriding vs not overriding a property in child.
a.x = {value: true};
b.x = {value: false};
What's the a.x?
So you can inherit objects as properties and still override them.