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

getting-started

Skill này làm gì

Skill này chỉ cách xây dựng một bảng trong ứng dụng Angular bằng TanStack Table, từ định nghĩa cột và dữ liệu đến hiển thị các hàng. Skill dành cho lập trình viên Angular muốn tự xây dựng bố cục bảng.

Khi nào nên dùng

  • ✓Khi bạn đang tạo một component Angular hiển thị danh sách bản ghi trong bảng.
  • ✓Khi dữ liệu bảng Angular của bạn đến từ signal và phải làm mới trên màn hình.
  • ✓Khi bạn muốn thêm tính năng Query hoặc Virtual vào bảng Angular.

Liên kết skill

https://github.com/TanStack/table/blob/main/packages/angular-table/skills/getting-started/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/getting-started/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

“Tôi cần một bảng trong ứng dụng Angular để hiển thị danh sách đơn hàng. Tôi thiết lập nó như thế nào?”

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

Cách hoạt động

Skill giải thích cách gọi injectTable bên trong một component, truyền cột và dữ liệu, rồi lặp qua các hàng trong template bằng directive FlexRender.

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#core first for the headless model, stable inputs, and column inference.

Setup

import { Component, signal } from '@angular/core'
import { FlexRender, injectTable, tableFeatures } from '@tanstack/angular-table'

type Person = { name: string; age: number }
const features = tableFeatures({})
const columns = [
  { accessorKey: 'name', header: 'Name' },
  { accessorKey: 'age', header: 'Age' },
]

@Component({
  selector: 'app-table',
  imports: [FlexRender],
  template: `<table>
    <tbody>
      @for (row of table.getRowModel().rows; track row.id) {
        <tr>
          @for (cell of row.getAllCells(); track cell.id) {
            <td>
              <ng-container *flexRenderCell="cell; let value">{{
                value
              }}</ng-container>
            </td>
          }
        </tr>
      }
    </tbody>
  </table>`,
})
export class TableComponent {
  readonly data = signal<Person[]>([{ name: 'Ada', age: 36 }])
  readonly table = injectTable(() => ({ features, columns, data: this.data() }))
}

Construction and rendering

Call injectTable in a component, directive, or service field initializer, or another valid Angular injection context. The adapter binds its cleanup to that context.

Signals read in the options initializer rerun it and call setOptions. Keep features, factories, and columns outside the initializer; return stable data references and derive transformed data with computed outside it.

Import FlexRender for *flexRender, *flexRenderCell, *flexRenderHeader, and *flexRenderFooter. Render values can be primitives, TemplateRef, component types, or flexRenderComponent(...). Use flexRenderComponent for Angular component types; ordinary render functions are already supported directly.

Read for the task

  • When adding or configuring optional features, load intent load @tanstack/table-core#table-features and read only references for the requested behavior.
  • For state ownership or reactive reads, read table-state.
  • When tables share features, defaults, or reusable UI, read create-table-hook.
  • When Query supplies data or server processing, read with-tanstack-query.
  • When virtualizing rows or columns, read with-tanstack-virtual.
  • When upgrading v8 code, read migrate-v8-to-v9.

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 nên gọi injectTable ở đâu?

Trong một component hoặc một trường của service, hoặc trong một injection context hợp lệ khác của Angular, để việc dọn dẹp được xử lý cho bạn.

Điều gì xảy ra khi dữ liệu của tôi là một signal?

Các tùy chọn được chạy lại khi signal thay đổi, nên bảng cập nhật với các giá trị mới.

Các cột có nên được định nghĩa bên ngoài component không?

Skill khuyên giữ các tính năng và cột bên ngoài các tùy chọn phản ứng, để chúng không bị dựng lại ở mỗi lần cập nhật.

Chi tiết

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

Create and render Table v9 with the angular adapter. Route reusable createTableHook components, Query and Virtual integration, and framework setup; use table-state for reactive ownership.

repo: TanStack/table

Độ phổ biến

Sao GitHub
29k
Vị trí xếp hạng
#9808
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ự