Catch event on template/variable changing in custom plugin develop

Hi!

Is there a way to intercept the event of the change of a dashboard variable?

39

Something similar to this:

this.events.on('template-changed', this.onTemplateChange.bind(this));

Or maybe there are better ways to act?

Thanks so much

1 Like

Found!

constructor($rootScope, $scope, $injector, $http, templateSrv) {
  ...
  $rootScope.onAppEvent('template-variable-value-updated', this.onVarChanged.bind(this), $scope);
  ...
}

...

onVarChanged() {
  ...
}

Thanks.

Bye!

2 Likes

Hi @novalabs, I cannot make it work on Grafana 6. Did you made it work ?

Thanks a lot.

Any update ? did u solve this