I am facing a challenge in sending a JSON object with a function template from app.controller
to another directive controller. I have chosen to pass this variable as an attribute of the inner directive's element. The issue arises when attempting to access the object within $attr.valueAtt
in my directive controller, as it only returns "[object Object]"
.
This is my code snippet:
var value = (
[{
functionLabel:'Fun',
functionTemplate: function(param1,param2){
alert(param1);
},
functionParams: ['PARAM1','PARAM2']
}]);
Subsequently, I include it in the controller as an attribute of the directive element:
angular.element(document.getElementById('space-for-modals'))
.append($compile("<modal-dialog visible='true' data-backdrop='static' valueAtt='"+value+"'></<modal-dialog>")($scope));
When trying to retrieve "value" in my directive controller:
$scope.functions= $attrs.valueAtt;
However, within $scope.functions
, only "[object Object]" is stored. Is there a technique available to successfully send a function template from one controller to another for future calling?