Referencing the Handsontable instance

优质
小牛编辑
127浏览
2023-12-01

An implementation of the @handsontable/angular explaining how to reference the Handsontable instance from the wrapper component.

// app.component.ts import { Component } from '@angular/core'; import * as Handsontable from 'handsontable'; import { HotTableRegisterer } from '@handsontable/angular'; @Component({ selector: 'app-root', template: `
`, }) class AppComponent { private hotRegisterer = new HotTableRegisterer(); id = 'hotInstance'; hotSettings: Handsontable.GridSettings = { data: Handsontable.helper.createSpreadsheetData(4, 4), colHeaders: true }; swapHotData() { this.hotRegisterer.getInstance(this.id).loadData([['new', 'data']]); } } // app.module.ts import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { HotTableModule } from '@handsontable/angular'; @NgModule({ imports: [ BrowserModule, HotTableModule.forRoot() ], declarations: [ AppComponent ], bootstrap: [ AppComponent ] }) class AppModule { } // bootstrap import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; platformBrowserDynamic().bootstrapModule(AppModule).catch(err => { console.error(err) });

Edit this page