How to get template variables for legacy AngularJS plugins now `variableSrv` has been removed?

We have a couple of legacy AngularJS plugins that use variableSrv to get template variables.

The Grafana instances have been upgraded to 7.4.0 and the plugins are now broken as variableSrv is no longer available.

I have tried installing the @grafana/runtime so I can maybe use getTemplateSrv, but I get a shedload of dependancy errors.

Is there a solution to this apart from converting the plugins to React?

This has been fixed by using the templateSrv service instead, and its getVariables method.

Edit: Actually it seems templateSrv.getVariables() is not available in v6.0.2, but templateSrv.variables is available in both v6.0.2 and v7.4.2.

1 Like