import { PipeTransform , Pipe } from '@angular/core' ; example @ Pipe ( { name : 'yn' } ) export class YNPipe implements PipeTransform { transform ( value , yes , no ) { if ( value === true ) { return '<span class="badge badge-success">' + ( yes || '是' ) + '</span>' ; } else { return '<span class="badge badge-error">' + ( no || '否' ) + '</span>' ; } } }