2

I am trying to use eval from javascript to call a function in angular.js. I have its name in string

I used the following:

$scope.$eval("$scope.drawFactory.draw")({},$scope.paint); 

But it's showing

TypeError: $scope.$eval(...) is not a function

What is the proper way to do this?

2

1 Answer 1

1

You could pass expression(string)/function to $eval which will evaluated against controller scope. No need to use $scope for $eval string.

$scope.$eval("drawFactory.draw") 

Where as you are doing $eval function & again calling that function call by

//below is obviously gonna throw an error $scope.$eval("$scope.drawFactory.draw")({},$scope.paint); //incorrect function execution 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.