Error when providing AppState to an embeded visualization

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.