Hi.
In a my custom plugin, I wrote a angular service.
Now that service is useful to other custom plugins too.
Is it possible to share it? Just like others Grafana core services that can be imported in many controllers…
Thanks so much.
Hi.
In a my custom plugin, I wrote a angular service.
Now that service is useful to other custom plugins too.
Is it possible to share it? Just like others Grafana core services that can be imported in many controllers…
Thanks so much.
Hi
Somehow like this
import coreModule from 'app/core/core_module';
class MyService {
seyHello() {
console.log('Hello');
}
}
coreModule.service('mySrv', MyService);
class MyPanelCtrl extends PanelCtrl {
constructor($scope, $injector, mySrv) {
super($scope, $injector);
mySrv.seyHello();
}
}
Thank you.
Your snippet is very useful to create a Service and to register it in coreModule.
But I have two different custom plugin (e.g.: MyPanel1 and MyPanel2) that appear occasionally together in the same dashboard (while other times alone). Every plugin needs MyService.
MyService class code should be present in both plugins?
If not, how can I use MyService in MyPanel1 if MyService class lives in MyPanel2 that is not loaded yet?
Thanks!