1

I'm using this custom made pipe:

import { Pipe, PipeTransform } from '@angular/core';
import { Observable } from 'rxjs';

@Pipe({
  name: 'yesno'
})
export class YesNoPipe implements PipeTransform {
    constructor() {}

    transform(observable: Observable<Array<any>>, args: Array<any>): Observable<Array<any>> {
        console.log(args);
        return observable...
    }
}

Into my template, I'm using:

<div>
    {{cols | yesno:'yesno':true | async | json}}
</div>

However, I'm only receiving only first argument "yesno".

Any ideas?

Jordi
  • 20,868
  • 39
  • 149
  • 333

2 Answers2

1

You have to use a rest parameter for your arguments in transform

// notice the three dots at: ...args
transform(observable: Observable<any[]>, ...args: any[]): Observable<any[]> {
  console.log(args);
  return observable...
}
frido
  • 13,065
  • 5
  • 42
  • 56
-1

you can pass multiple argument with ":" see below example

{{ cols | yesno:'yesno':true | async | json }}

Also please check pipe code below :

export class YesNoPipe implements PipeTransform {    
        transform(value:any, args:any[]):any {
                var arg1 = args[0];
                var arg2 = args[1];
                ...
        }
pmayur25
  • 11
  • 1