How to inject service into controller of kibana plugin?


(Sai Zin Han Hlaing) #1

I created new plugin and in that plugin I write one controller and one service.
So I would like to inject that service into a controller. How could I do this ?
So can anyone give me a solution ?
Thank you !


(Jon Budzenski) #2

Using your apps module (or create a new one and make it a dependency of your apps module), you have to register your service and then add it as an argument to your controller

const app = require*'ui/modules').get('app/namespace');
app.service('CustomService', () => {

});
app.controller('myController', function(CustomService) {

})

(Sai Zin Han Hlaing) #3

Thank you for your suggestion. I will check it. :grinning:


(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.