Hi Thasis,

I answered your question on SO. Will copy the answer in here for people not 
wanting to switch over.

Probably not what you want to hear, but the best solution is switching to 
the controllerAs way of working, and stop using $scope completely. You can 
read about this in the style-guide 
<https://github.com/johnpapa/angular-styleguide>. The problem you have is 
not caused by the .test variable on the ngIf directive, but rather by the 
way transclusion works. In combination with the isolation you are using, it 
gets unpredictable.

A mild uniqueness of this situation is that scope A is also an isolate 
scope, but given that everything is a child scope of it/part of its 
template that shouldn't matter.

O yes, this does matter! I don't recall the version, but this 'leakage' bug 
is fixed, and won't work anymore in the later AngualrJS versions. (and 
that's not even the whole problem)

You would really do yourself a favour, when you switch over to the (not so) 
new way of working with components, and controllerAs. Named controllers 
will fix this issue. Converting your directives to components, and using a 
controller instead of a link function is actually not that difficult, and 
it saves you from all kinds of surprises like this.

Oh, and probably introducing the dot, will help, but given your setup with 
isolated $scopes, combined with transclusion, I would not be convinced it's 
a 100% cure in all cases.

Regards
Sander

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" 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 https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to