Currently, I am working on developing an AngularJS application and have come across a particular challenge that needs to be addressed:
After making a web service call, I receive JavaScript code that looks like this:
{
"script":"function foo(a, b) { c = bar(a,b) $scope.c = c } function bar(a,b) { return a+b }"
}
My goal is to invoke the foo(a,b) function in my AngularJS application and have the property c within my $scope reflect the result from the bar(a,b) function.
Is it feasible for the foo(a,b) function to access $scope? What if there are existing functions named foo() or bar() within my application?
I've tried exploring solutions using eval and Function() features in JavaScript. However, I'm uncertain whether those can resolve my issue effectively.
pass function in json and execute
Your assistance or recommendations on this matter would be highly valued :)
Cheers,
Kevin