# Error when providing AppState to an embeded visualization

**URL:** <https://discuss.elastic.co/t/error-when-providing-appstate-to-an-embeded-visualization/106231>\
**Category:** Kibana\
**Created:** [November 2, 2017, 6:00pm UTC](https://discuss.elastic.co/t/error-when-providing-appstate-to-an-embeded-visualization/106231 "2017-11-02T18:00:40Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![havidarou](https://avatars.discourse-cdn.com/v4/letter/h/3ec8ea/32.png) [@havidarou](https://discuss.elastic.co/u/havidarou)\
**Post date:** [November 2, 2017, 7:45pm UTC](https://discuss.elastic.co/t/error-when-providing-appstate-to-an-embeded-visualization/106231/2 "2017-11-02T19:45:41Z")

</div>

I changed the AppState initialization like this (adding the getAppState service in my controller):

```
let currentAppState = getAppState();
  if (!currentAppState) {
      $scope.state = new AppState(getStateDefaults());
}

  function getStateDefaults() {
      return {
          query: '',
          index: 'c78aa9f0-bfec-11e7-bd67-eb6db07d9b4b',
          interval: 'auto',
          filters: {}
      };
  }

```

I'm using some hardcoded defaults for the appState initialization.

Then I use it as param in my embed visualization:

```
  $scope.$watch('selectedVisualization', () => {
    if (!$scope.selectedVisualization) return;
    visualizeLoader.embedVisualizationWithId(visContainer, $scope.selectedVisualization, {
      timeRange: timeRange, appState: $scope.state
    }).then(handler => {
      console.log('render complete');
    });
  });

```

But it's not affecting at all the visualization.

Regards.

---

_[View the full topic](https://discuss.elastic.co/t/error-when-providing-appstate-to-an-embeded-visualization/106231)._
