SoFunction
Updated on 2025-04-13

Detailed explanation of $eval method in angularjs

Define a variable in the controller

$scope.a_1 = "abc";

I want to output dynamically in the view, because this number is dynamic, so the output is definitely not possible {{'a_' + '1'}}, because the output is the string a_1, not the value of the variable a_1

To output the value of the variable a_1, you can use the $eval method:{{$eval('a_' + '1')}}

$eval is used as a scope method. If used in controller, it is used like this:$scope.$eval()

The above detailed explanation of the $eval method in angularjs is all the content I share with you. I hope you can give you a reference and I hope you can support me more.