Chuyển đến nội dung
Skillpedia
Website và giao diện (frontend)29k · #9810

table-state

Skill này làm gì

Skill này giải thích cách trạng thái bảng, như trang hiện tại, hoạt động trong một ứng dụng Angular xây dựng trên signal. Skill dành cho lập trình viên cần bảng và các component của họ phản ứng với cùng một giá trị.

Khi nào nên dùng

  • ✓Khi một template phải hiển thị số trang hiện tại hoặc một thiết lập khác của bảng.
  • ✓Khi bạn cần nối thiết lập trang của bảng với một signal Angular.
  • ✓Khi một giá trị tính toán hoặc effect không cập nhật sau khi bảng thay đổi.

Liên kết skill

https://github.com/TanStack/table/blob/main/packages/angular-table/skills/table-state/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/TanStack/table/blob/main/packages/angular-table/skills/table-state/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Làm sao để hiển thị số trang hiện tại từ bảng Angular của tôi trong nhãn của một nút?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Skill chỉ cách giữ trạng thái bảng trong một signal, truyền nó cho bảng và cập nhật qua các callback, để hai bên luôn đồng bộ.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Load intent load @tanstack/table-core#table-state first for shared ownership, initialization, updater, and reset rules.

Angular-backed atom reads participate in tracking inside templates, computed, and effect. A value captured outside those contexts is only a snapshot. Use computed for derivation or equality control; wrapping an atom is not required to make it reactive.

Controlled signal setup

<!-- skill-snippet:check tsconfig=scripts/skill-snippets-angular.tsconfig.json -->
import { Component, signal } from '@angular/core'
import {
  injectTable,
  rowPaginationFeature,
  tableFeatures,
} from '@tanstack/angular-table'

const features = tableFeatures({ rowPaginationFeature })
const columns = [{ accessorKey: 'name' }]
const data = [{ name: 'Ada' }]

@Component({
  selector: 'page-status',
  template: `<button (click)="table.nextPage()">
    Page {{ table.atoms.pagination.get().pageIndex + 1 }}
  </button>`,
})
export class PageStatus {
  readonly pagination = signal({ pageIndex: 0, pageSize: 20 })
  readonly table = injectTable(() => ({
    features,
    columns,
    data,
    state: { pagination: this.pagination() },
    onPaginationChange: (next) =>
      typeof next === 'function'
        ? this.pagination.update(next)
        : this.pagination.set(next),
  }))
}

Reactive boundaries

  • Construct in Angular injection context. Signal writes used by the initializer rerun it and call setOptions; hoist features and columns and keep data references stable.
  • Supply both state.pagination and onPaginationChange when a signal owns the slice. Resolve updater functions with .update(next) instead of storing the function with .set(next).
  • For shared state, create a stable atom with @tanstack/angular-store and pass it through atoms. Its writes do not need to flow through a controlled signal in the initializer.
  • Use table.store.get() for the flat state. Prefer table.atoms.<slice>.get() for narrow tracked reads.

Read for the task

For advanced reactive boundaries, shared atoms, or detailed subscription examples, read reactivity. For construction or rendering setup, read getting-started.

API discovery

Inspect node_modules/@tanstack/angular-table/dist/types/ for the bundled public declarations. Inspect feature APIs under node_modules/@tanstack/table-core/dist/features/.

Câu hỏi thường gặp

Tôi có luôn cần một hàm trợ giúp đặc biệt để làm một giá trị có tính phản ứng không?

Không. Skill cho biết không bắt buộc phải bọc giá trị trong một hàm trợ giúp để nó phản ứng.

Vì sao giá trị tôi đã sao chép không cập nhật?

Một giá trị được đọc bên ngoài template, computed hoặc effect chỉ là một bản chụp nhanh, nên nó không tự làm mới.

Bảng phải được tạo ở đâu?

Bảng được tạo bằng injectTable, và hàm này phải chạy trong một injection context của Angular.

Chi tiết

Mô tả gốc của tác giả

Read and control Table v9 state in angular. Use for tracked reads, subscriptions, controlled slices, and framework-specific reactive boundaries.

repo: TanStack/table

Độ phổ biến

Sao GitHub
29k
Vị trí xếp hạng
#9810
Giấy phép
MIT
Cập nhật
21/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự