# How to call vis object in the controller?

**URL:** <https://discuss.elastic.co/t/how-to-call-vis-object-in-the-controller/60066>\
**Category:** Kibana\
**Created:** [September 8, 2016, 11:34am UTC](https://discuss.elastic.co/t/how-to-call-vis-object-in-the-controller/60066 "2016-09-08T11:34:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![YuWatanabe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuwatanabe/32/13259_2.png) [@YuWatanabe](https://discuss.elastic.co/u/YuWatanabe)\
**Post date:** [September 8, 2016, 11:34am UTC](https://discuss.elastic.co/t/how-to-call-vis-object-in-the-controller/60066/1 "2016-09-08T11:34:22Z")

</div>

According to below site, variables set in the visualization are available as **[vis.params.xxx](http://vis.params.xxx)** in template.

> **[Writing Kibana 4 Plugins – Simple Visualizations](https://www.timroes.de/2015/12/02/writing-kibana-4-plugins-simple-visualizations/)**
>
> This tutorial series explains how to create own Kibana plugins. This part explains
> how to create a simple visualization that doesn't use any data yet.

However, I want to use the vis.params in **the controller** instead of template.  
When I do this, I get below errors when I try to call the vis object in the controller.

```
ReferenceError: vis is not defined
    at Object.fn (linechart-rj-cont.js:104)
    at Scope.$digest (angular.js:15826)
    at Scope.$apply (angular.js:16097)
    at HTMLTableCellElement.<anonymous> (angular.js:23554)
    at HTMLTableCellElement.dispatch (jquery.js:4435)
    at HTMLTableCellElement.elemData.handle (jquery.js:4121)

```

Below is the snippet of my code from controller.

```
// Build query for arm
$scope.robot_name = filters[0].query.match[$scope.tbl_key1].query;

$scope.data_type = vis.params.data_type;
$scope.parts_name = vis.params.thold_type;

```

Below is my template in visualiation.

```
<input type="radio" ng-model="vis.params.data_type" value="run">
  <label>
  test1
  </label><br/>
<input type="radio" ng-model="vis.params.data_type" value="jump_r">
  <label>
  test2
  </label><br/>

```

How can I call vis object in the controller? If I cant, how can I use the variables which is set in visualization in the controller?

---

<div class="post-metadata">

**Author:** ![YuWatanabe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuwatanabe/32/13259_2.png) [@YuWatanabe](https://discuss.elastic.co/u/YuWatanabe)\
**Post date:** [September 8, 2016, 10:24pm UTC](https://discuss.elastic.co/t/how-to-call-vis-object-in-the-controller/60066/2 "2016-09-08T22:24:21Z")

</div>

I solved this by myself.

Accessing **vis.params.data\_type** in template means vis object is stored in **$scope**.  
Which means , I could access in controller by **$scope.vis.params.xx**

---

<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:** [September 8, 2016, 10:27pm UTC](https://discuss.elastic.co/t/how-to-call-vis-object-in-the-controller/60066/3 "2016-09-08T22:27:29Z")

</div>

Glad you figured it out!

---

<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:39pm UTC](https://discuss.elastic.co/t/how-to-call-vis-object-in-the-controller/60066/4 "2017-07-06T13:39:17Z")

</div>


