How can I save uiState in a Visualization?

I am writing a new Visualization plugin for kibana 5.1.
And I want to save the ui config object into uiStateJSON.

config: {
  rows: [],
  cols: [],
  aggregatorName: "Count",
  vals: []

tried $scope.uiState=$scope.table.config; in controller
but it does not work.

The uiState object has get and set methods that you should use to read/write data on it. It will be easier if you also use it as your single source of data:

uiModule.controller('MyController', class {
  constructor($scope) {
    /* read the rows from the uiState, or return the default (an empty array) */
    this.getRows = () => $scope.uiState.get('rows', [])

    /* change the rows saved in the uiState */
    this.setRows = (newRows) => $scope.uiState.set('rows', newRows)

  /* add an empty row to the end of the row state */
  addEmptyRow() {

  /* delete the last row in the row state */
  removeLastRow() {
    this.setRows(this.getRows().slice(0, -1))

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