Skip to content

[Angular] How to return a component for a cell? #5662

Answered by mathieuszek
rosensama asked this question in Q&A
Discussion options

You must be logged in to vote

Hello, did you try with something like: https://tanstack.com/table/latest/docs/framework/angular/angular-table?

In my case I needed to display column with percent pipe:

interface X {
    percentageValue: number,
}

public readonly columns: ColumnDev<X>[] = [{
    accessorKey: 'percentageValue',
    cell: data => new FlexRendererComponent(PercentageCellComponent, { value: data.getValue<number>(), }),
}];
@Component({
  standalone: true,
  selector: 'app-table-percentage-cell',
  imports: [PercentPipe],
  template: `
    {{ value() | percent }}
  `,
})
export class PercentageCellComponent {

  public readonly value = input.required<number>();

}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@rosensama
Comment options

Answer selected by rosensama
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants