I've encountered a situation that seems to be the opposite of every similar question here on StackOverflow.
I've got a <scroll>
directive, that simply wraps whatever content it has with a scrollable div
of some sort. It looks more or less like this:
.directive('scroll', ['$document','$parse', function ($document,$parse) {
return {
restrict: 'E',
replace: true,
transclude: true,
scope:false,
template:
'<div class="scroll">' +
'<div class="content" data-ng-transclude>' +
'</div>' +
'</div>',
link: function (scope, element, attr) {
// some code here....
}
};
}]);
This works great in itself.
Now, I've got another directive called <editor>
that has an isolated scope and uses <scroll>
within it's template. <editor>
looks more or less like:
.directive('editor', ['$document', function ($document){
return {
restrict: 'EA',
replace: true,
transclude: false,
scope:true,
template:
'<div>' +
'....<scroll>....</scroll>....' +
'</div>',
link: function (scope, element, attrs) {
.....
}
};
}]);
Now, here's the deal: I need to access <editor>
's scope from within <scroll>
's link function (where it says "some code here"), but for some reason I can't. The scope
variable in <scroll>
's link function is pretty much empty, and scope.$parent
gives me the controller above, skipping the <editor>
that's supposed to be in the way.
I've tried playing with ng-transclude
in different places in the <editor>
and tried using $emit
and I'm really clueless about this - I would think that scope isolation would isolate "me and everything below me" from what's above, but it seems that scope isolation just takes "me" out of the scope tree...
Hope this is clear enough, thanks.