# Kibana plugin controller inject error

**URL:** <https://discuss.elastic.co/t/kibana-plugin-controller-inject-error/63402>\
**Category:** Kibana\
**Created:** [October 19, 2016, 2:04pm UTC](https://discuss.elastic.co/t/kibana-plugin-controller-inject-error/63402 "2016-10-19T14:04:43Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Echyzen](https://avatars.discourse-cdn.com/v4/letter/e/b5ac83/32.png) [@Echyzen](https://discuss.elastic.co/u/Echyzen)\
**Post date:** [October 19, 2016, 2:04pm UTC](https://discuss.elastic.co/t/kibana-plugin-controller-inject-error/63402/1 "2016-10-19T14:04:43Z")

</div>

Hello I try to make a hello world plugin inside kibana so I use the yeoman generator but there is the following error:  
[ng:areq] Argument 'pluginTestHelloWorld' is not a function, got undefined

I show my index.js

> import exampleRoute from './server/routes/example';

> export default function (kibana) {  
> return new kibana.Plugin({  
> require: ['kibana', 'elasticsearch'],  
> uiExports: {  
> app: {  
> title: 'CloudUnit',  
> description: 'A CloudUnit plugin',  
> main: 'plugins/cloudunit\_kibana/app',
> 
> ```
> injectVars: function (server, options) {
> var config = server.config();
> return {
> kbnIndex: config.get('kibana.index'),
> esShardTimeout: config.get('elasticsearch.shardTimeout'),
> esApiVersion: config.get('elasticsearch.apiVersion')
> };
> }
> },
> visTypes: [
> 'plugins/cloudunit_kibana/vis_type'
> ],
> },
> 
> ```

> ```
> config(Joi) {
> return Joi.object({
> enabled: Joi.boolean().default(true),
> }).default();
> },
> 
> ```

> ```
> init(server, options) {
> // Add server routes and initalize the plugin here
> exampleRoute(server);
> }
> 
> ```
> 
> });  
> };

And this is my app.js which contains my "pluginTestHelloWorld" controller

> import moment from 'moment';  
> import chrome from 'ui/chrome';  
> import uiModules from 'ui/modules';  
> import uiRoutes from 'ui/routes';

> import 'ui/autoload/styles';

> //import './less/main.less';  
> import template from './templates/index.html';

> uiRoutes.enable();  
> uiRoutes  
> .when('/', {  
> template,  
> resolve: {  
> currentTime($http) {  
> return $http.get('../api/cloudunit\_kibana/example').then(function (resp) {  
> console.log(resp.data.time);  
> return resp.data.time;  
> });  
> }  
> },  
> controller: 'pluginTestHelloWorld'  
> });

> uiModules  
> .get('app/cloudunit\_kibana', )  
> .controller('pluginTestHelloWorld', function ($scope) {  
> $scope.title = 'Plugin Test';  
> $scope.description = 'An awesome Kibana plugin';

> var currentTime = moment($route.current.locals.currentTime);  
> $scope.currentTime = currentTime.format('HH:mm:ss');  
> var unsubscribe = $interval(function () {  
> $scope.currentTime = currentTime.add(1, 'second').format('HH:mm:ss');  
> }, 1000);  
> $scope.$watch('$destroy', unsubscribe);  
> });

Do you know why the ng-controller syntaxe in template make this issue?

---

<div class="post-metadata">

**Author:** ![lukas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas/32/6812_2.png) [@lukas](https://discuss.elastic.co/u/lukas)\
**Post date:** [October 19, 2016, 9:45pm UTC](https://discuss.elastic.co/t/kibana-plugin-controller-inject-error/63402/2 "2016-10-19T21:45:52Z")

</div>

Are you specifying `ng-controller="pluginTestHelloWorld"` in the template in addition to specifying it in the definition of the route?

---

<div class="post-metadata">

**Author:** ![Echyzen](https://avatars.discourse-cdn.com/v4/letter/e/b5ac83/32.png) [@Echyzen](https://discuss.elastic.co/u/Echyzen)\
**Post date:** [October 20, 2016, 8:30am UTC](https://discuss.elastic.co/t/kibana-plugin-controller-inject-error/63402/3 "2016-10-20T08:30:22Z")

</div>

Yes of course this is the template:  
`<div class="container" ng-controller="pluginTestHelloWorld">`

> ## Congratulations
> 
> You've successfully created your first Kibana Plugin!
> 
> # {{ title }}
> 
> {{ description }}
> 
> The current time is {{ currentTime }}

---

<div class="post-metadata">

**Author:** ![lukas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas/32/6812_2.png) [@lukas](https://discuss.elastic.co/u/lukas)\
**Post date:** [October 20, 2016, 3:26pm UTC](https://discuss.elastic.co/t/kibana-plugin-controller-inject-error/63402/4 "2016-10-20T15:26:37Z")

</div>

Could you try removing this line, as it's unnecessary if you're using `ng-controller`:

> [@](#):
>
> `controller: 'pluginTestHelloWorld'`

---

<div class="post-metadata">

**Author:** ![Echyzen](https://avatars.discourse-cdn.com/v4/letter/e/b5ac83/32.png) [@Echyzen](https://discuss.elastic.co/u/Echyzen)\
**Post date:** [October 20, 2016, 4:54pm UTC](https://discuss.elastic.co/t/kibana-plugin-controller-inject-error/63402/5 "2016-10-20T16:54:25Z")

</div>

It's same problem I add this notation in order to bypass the problem but the is already the same issue :S

I don't understand because angular it's correctly instanciate but no possibility to declare a controller

You didn't have a git repo with a hello world plugin? because the generator yeoman doesn't operate correctly

Thanks for all

---

<div class="post-metadata">

**Author:** ![lukas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas/32/6812_2.png) [@lukas](https://discuss.elastic.co/u/lukas)\
**Post date:** [October 21, 2016, 4:04pm UTC](https://discuss.elastic.co/t/kibana-plugin-controller-inject-error/63402/6 "2016-10-21T16:04:24Z")

</div>

Can you share your package.json file contents? And what version of Kibana are you working with?

---

<div class="post-metadata">

**Author:** ![Echyzen](https://avatars.discourse-cdn.com/v4/letter/e/b5ac83/32.png) [@Echyzen](https://discuss.elastic.co/u/Echyzen)\
**Post date:** [October 24, 2016, 7:20am UTC](https://discuss.elastic.co/t/kibana-plugin-controller-inject-error/63402/7 "2016-10-24T07:20:59Z")

</div>

Yes of course,

I work with kibana 4.4, 4.6, 5.0 and master branch of kibana repository.

And this is my package.json:

> {  
> "name": "cloudunit\_kibana",  
> "version": "0.0.0",  
> "description": "An awesome Kibana plugin",  
> "main": "index.js",  
> "scripts": {  
> "lint": "eslint",  
> "start": "plugin-helpers start",  
> "test:server": "plugin-helpers test\_server",  
> "test:browser": "plugin-helpers test\_browser",  
> "build": "plugin-helpers build",  
> "postinstall": "plugin-helpers postinstall"  
> },  
> "devDependencies": {  
> "@elastic/eslint-config-kibana": "0.0.2",  
> "babel-eslint": "4.1.8",  
> "eslint": "1.10.3",  
> "eslint-plugin-mocha": "1.1.0",  
> "@elastic/plugin-helpers": "5.0.0-beta1",  
> "babel-runtime": "^5.0.0"  
> },  
> "dependencies": {  
> "@elastic/eslint-config-kibana": "0.0.2",  
> "@elastic/plugin-helpers": "5.0.0-beta1",  
> "babel": "5.8.23",  
> "babel-core": "5.8.23",  
> "babel-eslint": "4.1.8",  
> "babel-loader": "5.3.2",  
> "babel-runtime": "5.8.20",  
> "eslint": "1.10.3",  
> "eslint-plugin-mocha": "1.1.0",  
> "httpolyglot": "^0.1.1",  
> "moment": "^2.15.1",  
> "raw-loader": "^0.5.1",  
> "rjs-repack-loader": "^1.0.6"  
> }  
> }

---

<div class="post-metadata">

**Author:** ![lukas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas/32/6812_2.png) [@lukas](https://discuss.elastic.co/u/lukas)\
**Post date:** [October 28, 2016, 3:42pm UTC](https://discuss.elastic.co/t/kibana-plugin-controller-inject-error/63402/8 "2016-10-28T15:42:59Z")

</div>

Are you getting errors about versioning? The version in your package.json should match the version of Kibana you're targeting.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:35pm UTC](https://discuss.elastic.co/t/kibana-plugin-controller-inject-error/63402/9 "2017-07-06T13:35:20Z")

</div>


