Closed muser83 closed 10 years ago
Hello there is not straightforward as the blocks array is in a private closure
however you can change the code
var blocks=[];
by
var blocks=this.blocks=[];
so that the blocks are available on the controller ctrl.blocks
Laurent
Ok I have added a method to expose blocks property in flexyLayout controller like this:
this.getBlocks = function() {
return blocks;
};
But... How can I call getBlocks from my app controller or from another directive? I am a newbie in AngularJS... Sorry
I have tried this, but launches a flexylayout controller not found error:
angular.module('controlRoom').directive('flexyLayoutDebugger', function() {
return {
restrict: 'A',
require: '^flexyLayout',
link: function(scope,element,attrs, flexyLayoutCtrl) {
element.bind("mouseenter", function(){
console.log(flexyLayoutCtrl.getBlocks());
});
}
}
});
require:'^anyController'
imply that your directive expect to find a parent ont the dom tree which has the anyController directive attached (refer to documentationhttp://docs.angularjs.org/guide/directive )
so
...
will works when
will throw Exception
Laurent
On Fri, Jan 17, 2014 at 9:26 AM, muser83 notifications@github.com wrote:
Ok I have added a method to expose blocks property in flexyLayout controller like this:
this.getBlocks = function() { return blocks; };
But... How can I call getBlocks from my app controller or from another directive? I am a newbie in AngularJS... Sorry
I have tried this, but launches a flexylayout controller not found error:
angular.module('controlRoom').directive('flexyLayoutDebugger', function() { return { restrict: 'A', require: '^flexyLayout', link: function(scope,element,attrs, flexyLayoutCtrl) { element.bind("mouseenter", function(){ console.log(flexyLayoutCtrl.getBlocks()); }); } } });
— Reply to this email directly or view it on GitHubhttps://github.com/lorenzofox3/flexy-layout/issues/12#issuecomment-32587526 .
Yes, that was it! Thank you!
Hello
I want to print with json the current structure of the Flexy layout from my app. How can get it done?