0

I am building an app in Angular 11. I am unable to bind sackCreated event, please let me know if its deprecated or it has some alternative. Below is my code.

 this._goldenLayout.on('stackCreated', (stack) => {
      if (stack._target._contentItems.length > 0) {
        var current = this;
        var filterPopIcon: JQuery = $('<i class="pi pi-filter" id="filterPopIcon" style="margin-top:3px;margin-left:2px;cursor:pointer"/>');
        filterPopIcon.off().on('click', function () {
         
          if (stack._target._activeComponentItem._container._state.length > 2) {
            current.hierarchyService.goldenLayoutChanged.next(stack._target._activeComponentItem._container._state[0])
          }
        })
        var elementCounter: Element = filterPopIcon.get(0);
        stack._target._header.controlsContainer.prepend(elementCounter);
      }

    });

I am unable to find this event in index.d.ts file as well.Getting this error Argument of type '"stackCreated"' is not assignable to parameter of type '"hide" | "show" | "closed" | "open" | "blur" | "close" | "drag" | "focus" | "resize" | "shown" | "tab" | "__all" | "activeContentItemChanged" | "destroy" | "dragStart" | "dragStop" | ... 16 more ... | "userBroadcast"'

Billz
  • 1,067
  • 6
  • 25
  • 57

1 Answers1

0

This event was removed in Golden Layout 2. Instead use itemCreated and check if the event's target is a Stack:

this._goldenLayout.on('itemCreated', e => {
    if(e.target.isStack) {
        ...
    }
});
Michael Mrozek
  • 169,610
  • 28
  • 168
  • 175