javascript - Dynamic variable for angular ng-click attribute -
i using following way use $scope variable ({{func}}() in case) function name in ng-click.
<button type="button" ng-click="{{func}}()">call {{func}}</button></pre> this works in angularjs-1.2.0rc3. see working plunkr here
any future version > 1.2.0rc3 throw error
what's changed? how can use above syntax in current angular version?
ok first of i not recommend such usage ng-click because angularjs not support this, if still want use such way here solution...
<button type="button" ng-click="$eval(functionname)()">...</button> where
$scope.f1 = function() { ... }; //name of function string $scope.functionname = "f1"; this looking , here plunker example...
Comments
Post a Comment