Currently, I am experiencing an issue with a parent scope that has a function name defined within a variable.
$scope.form.callback = "sayHello(msg)";
$scope.sayHello = function(msg) {
alert('Parent says ' + msg);
};
The parent template is structured like this:
<a sg-dir sg-callback="{{form.callback}}" href="">Click Me</a>
Below is the code for "sgDir":
someModule.directive("sgDir", function(){
return {
scope: {
sgCallback: "&"
},
link: function(scope, elem, attrs, ctrl) {
scope.sgCallback({msg:'Hello world!'});
}
};
});
However, this setup is resulting in an error message:
[$parse:syntax] Syntax Error: Token '{' invalid key at column 2 of the
expression [{{form.callback}}] starting at [{form.callback}}].
Please assist me with resolving this issue.
Update:
I need to keep the function name within a variable as per my requirements.