Reputation: 7596
So I have a directive that look like this:
(function (module) {
var node = function (RecursionHelper) {
return {
restrict: 'E',
controller: 'mainController',
scope: {
node: '=n'
},
templateUrl: '/app/NSviewer/templates/parts/node.html',
compile: function (element) {
// Use the compile function from the RecursionHelper,
// And return the linking function(s) which it returns
return RecursionHelper.compile(element);
}
};
};
module.directive("node", node);
}(angular.module("anbud")));
And I have a layout variable that is defined like this:
$rootScope.layout = "test";
In the node directive. The layout variable is not displayed.
<pre>{{layout | json}}</pre>
This shows up as empty.
How can I access $rootScope.layout from my node directive?
Upvotes: 1
Views: 477
Reputation: 1154
Hi you need to inject $rootScope
in your directive and try it this way:
{{$root.layout | json}}
Upvotes: 2