# Private in app plugin?

**URL:** <https://discuss.elastic.co/t/private-in-app-plugin/123666>\
**Category:** Kibana\
**Created:** [March 13, 2018, 2:10am UTC](https://discuss.elastic.co/t/private-in-app-plugin/123666 "2018-03-13T02:10:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![deadPix3l](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/deadpix3l/32/28707_2.png) [@deadPix3l](https://discuss.elastic.co/u/deadPix3l)\
**Post date:** [March 13, 2018, 2:10am UTC](https://discuss.elastic.co/t/private-in-app-plugin/123666/1 "2018-03-13T02:10:37Z")

</div>

I am developing an app plugin which needs to see the currently pinned filters. A previous post of mine and many searches reconfirm that I need to be using 'ui/filter\_bar/filter\_bar' but every reference I found to that calls Private(), which seems to be a parameter frequently passed to visualizations. My app does not get passed it and produces a "private is undefined" error.

Where does this come from and how can I receive this parameter, import it, or define it in an app?

---

<div class="post-metadata">

**Author:** ![spalger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spalger/32/14092_2.png) [@spalger](https://discuss.elastic.co/u/spalger)\
**Post date:** [March 14, 2018, 3:25am UTC](https://discuss.elastic.co/t/private-in-app-plugin/123666/2 "2018-03-14T03:25:23Z")

</div>

First, about `Private`: this is an angular service that is responsible for taking anonymous providers like [https://github.com/elastic/kibana/blob/4bbd127626e2a74d7fa75fc73ce69c2331938c28/src/ui/public/agg\_response/tabify/tabify.js#L5](https://github.com/elastic/kibana/blob/4bbd127626e2a74d7fa75fc73ce69c2331938c28/src/ui/public/agg_response/tabify/tabify.js#L5). It instantiates services much like `angular.module().service(name, provider)` does, except it doesn't require picking a name for the service and instead uses the provider as the key, requiring that you import the provider to get it's instance.

To get an instance of the `Private` service in your app you'll need to inject it somewhere like in your controller of directives:

```auto
import { uiModules } from 'ui/modules'
const module = uiModules.get('myModule')
module.service('myService', function (Private) {
  // Here you can use Private to get the instance of anonymous providers
});

```

For more information about `Private` checkout the docs in this file: [https://github.com/elastic/kibana/blob/master/src/ui/public/private/private.js](https://github.com/elastic/kibana/blob/master/src/ui/public/private/private.js)

* * *

I think the service you want is `ui/filter_bar/query_filter` [source](https://github.com/elastic/kibana/blob/master/src/ui/public/filter_bar/query_filter.js). You will need the `Private` loader to get access to this service, and it will look something like this:

```auto
import { FilterBarQueryFilterProvider } from 'ui/filter_bar/query_filter';
import { uiModules } from 'ui/modules';

uiModules.compoent('myComponent', function (Private) { 
  return {
    template: `
      <pre>{{$ctrl.globalFilters | json}}</pre>
    `,
    controller() {
      const filterBarQueryFilter = Private(FilterBarQueryFilterProvider);

      this.globalFilters = filterBarQueryFilter.getGlobalFilters()
    }
  }
});

```

---

<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:** [April 11, 2018, 3:25am UTC](https://discuss.elastic.co/t/private-in-app-plugin/123666/3 "2018-04-11T03:25:36Z")

</div>

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