0
Fork 0
mirror of https://github.com/TanStack/table.git synced 2026-11-18 18:55:54 +00:00
table/docs/framework/angular/reference/functions/injectTable.md
Kevin Van Cott 87c6bcc52a
feat(table-core): Further improve tree-shaking across features (#6626)
* feat(table-core): Further improve tree-shaking across features

Keep column ordering, column pinning, and row expanding code out of the
core bundle, route more cross-feature reads through feature stubs, and
stop allocating unused onAfterUpdate wrappers in production memos.

* refactor(table-core): register internal cross-feature fns as table APIs

Replace init*InstanceData function storage with @internal table APIs
registered via assignTableAPIs, route faceting through the
getCanGlobalFilter stub, and enforce feature boundaries with
import/no-restricted-paths. Regenerate reference docs and fix stale
docs config links.

---------
2026-10-12 09:51:47 -05:00

2.3 KiB

id title
injectTable injectTable
function injectTable<TFeatures, TData>(optionsFactory): AngularTable<TFeatures, TData>;

Defined in: packages/angular-table/src/injectTable.ts:90

Creates and returns an Angular-reactive table instance.

The initializer is intentionally re-evaluated whenever any signal read inside it changes. This is how the adapter keeps the table in sync with Angular's reactivity model.

Because of that behavior, keep expensive/static values (for example columns, feature setup, row models) as stable references outside the initializer, and only read reactive state (data(), pagination/filter/sorting signals, etc.) inside it.

The returned table is also signal-reactive: table state and table APIs are wired for Angular signals, so you can safely consume table methods inside computed(...) and effect(...).

Type Parameters

TFeatures

TFeatures extends TableFeatures

TData

TData extends RowData

Parameters

optionsFactory

() => TableOptions<TFeatures, TData>

Returns

AngularTable<TFeatures, TData>

An Angular-reactive TanStack Table instance.

Example

  1. Register the table features you need
// Register only the features you need
import {tableFeatures, rowPaginationFeature} from '@tanstack/angular-table';
const features = tableFeatures({
 rowPaginationFeature,
 // ...all other features you need
})

// Use all table core features
import {stockFeatures} from '@tanstack/angular-table';
const features = tableFeatures(stockFeatures);
  1. Prepare the table columns
import {ColumnDef} from '@tanstack/angular-table';

type MyData = {}

const columns: ColumnDef<typeof features, MyData>[] = [
  // ...column definitions
]

// or using createColumnHelper
import {createColumnHelper} from '@tanstack/angular-table';
const columnHelper = createColumnHelper<typeof features, MyData>();
const columns = columnHelper.columns([
 columnHelper.accessor(...),
 // ...other columns
])
  1. Create the table instance with injectTable
const table = injectTable(() => {
  // ...table options,
  features,
  columns: columns,
  data: myDataSignal(),
})