GridStack Angular Library - v13.0.0
    Preparing search index...

    Angular component wrapper for GridStack.

    This component provides Angular integration for GridStack grids, handling:

    • Grid initialization and lifecycle
    • Dynamic component creation and management
    • Event binding and emission
    • Integration with Angular change detection

    Use in combination with GridstackItemComponent for individual grid items.

    <gridstack [options]="gridOptions" (change)="onGridChange($event)">
    <div empty-content>Drag widgets here</div>
    </gridstack>

    Implements

    • OnInit
    • AfterContentInit
    • OnDestroy
    Index

    Accessors

    • get grid(): undefined | GridStack

      Get the underlying GridStack instance. Use this to access GridStack API methods directly.

      Returns undefined | GridStack

      this.gridComponent.grid.addWidget({x: 0, y: 0, w: 2, h: 1});
      

    Constructors

    Methods

    • Register Angular components for dynamic creation.

      Each component is keyed by its @Component.selector string, which becomes the component field value in widget JSON (same role as component in React/Vue).

      Parameters

      • typeList: Type<object>[]

        Array of component types to register

      Returns void

      GridstackComponent.registerComponents([MyWidgetComponent, AnotherWidgetComponent]);
      
    • A callback method that is invoked immediately after the default change detector has checked the directive's data-bound properties for the first time, and before any of the view or content children have been checked. It is invoked only once when the directive is instantiated.

      Returns void

    • called when the TEMPLATE (not recommended) list of items changes - get a list of nodes and update the layout accordingly (which will take care of adding/removing items changed by Angular)

      Returns void

    Properties

    gridstackItems?: QueryList<GridstackItemComponent>

    List of template-based grid items (not recommended approach). Used to sync between DOM and GridStack internals when items are defined in templates. Prefer dynamic component creation instead.

    container?: ViewContainerRef

    Container for dynamic component creation (recommended approach). Used to append grid items programmatically at runtime.

    isEmpty?: boolean

    Controls whether empty content should be displayed. Set to true to show ng-content with 'empty-content' selector when grid has no items.

    <gridstack [isEmpty]="gridItems.length === 0">
    <div empty-content>Drag widgets here to get started</div>
    </gridstack>
    addedCB: EventEmitter<nodesCB> = ...

    Emitted when widgets are added to the grid

    changeCB: EventEmitter<nodesCB> = ...

    Emitted when grid layout changes

    disableCB: EventEmitter<eventCB> = ...

    Emitted when grid is disabled

    dragCB: EventEmitter<elementCB> = ...

    Emitted during widget drag operations

    dragStartCB: EventEmitter<elementCB> = ...

    Emitted when widget drag starts

    dragStopCB: EventEmitter<elementCB> = ...

    Emitted when widget drag stops

    droppedCB: EventEmitter<droppedCB> = ...

    Emitted when widget is dropped

    enableCB: EventEmitter<eventCB> = ...

    Emitted when grid is enabled

    removedCB: EventEmitter<nodesCB> = ...

    Emitted when widgets are removed from the grid

    resizeCB: EventEmitter<elementCB> = ...

    Emitted during widget resize operations

    resizeStartCB: EventEmitter<elementCB> = ...

    Emitted when widget resize starts

    resizeStopCB: EventEmitter<elementCB> = ...

    Emitted when widget resize stops

    ref: undefined | ComponentRef<GridstackComponent>

    Component reference for dynamic component removal. Used internally when this component is created dynamically.

    componentMap: ComponentMap = {}

    Map of component keys to Angular component types used for dynamic creation. Keys default to the component's @Component.selector string when registered via registerComponents().

    _options?: GridStackOptions
    _grid?: GridStack
    _sub: undefined | Subscription
    loaded?: boolean
    elementRef: ElementRef<GridCompHTMLElement>