ng2-table icon indicating copy to clipboard operation
ng2-table copied to clipboard

Allow user to specify property 'pipe' on column object to allow for custom formatting pipes

Open mattvaughan opened this issue 8 years ago • 6 comments

What this will allow users to do is create a pipe object in their component and set the pipe property on their column:

columns:Array<any> = [
  {title: 'My Column Title', name: 'columnName', pipe: new MyPipe()}
]

For pipes like CurrencyPipe that take parameters, the user can make their own pipe that extends CurrencyPipe and pass the desired parameters. For example:

import { Pipe, PipeTransform, Injectable } from '@angular/core';
import { CurrencyPipe } from '@angular/common';

@Pipe({
  name: 'usd',
  pure: 'false'
})
@Injectable()
export class USDPipe extends CurrencyPipe {
  constructor() {
    super("en-US");
  }

  public transform(money:number):string {
    return super.transform(money, "USD", true);
  }
}

mattvaughan avatar Oct 20 '16 22:10 mattvaughan

I believe this is what #250 is asking for.

mattvaughan avatar Oct 20 '16 23:10 mattvaughan

👍

mdw233 avatar Dec 06 '16 19:12 mdw233

would like to see this feature coming into a next version

Sevyls avatar Mar 17 '17 15:03 Sevyls

Can this be merged?

jessiejuachon avatar Oct 21 '17 00:10 jessiejuachon

When shall we be able to benefit from this feature ?

JabCorp avatar Nov 29 '17 16:11 JabCorp

Hi guys, any example of this feature? I have problems to apply date pipe.

iariasfallas avatar May 09 '18 17:05 iariasfallas