Angular 2 延伸现有管道
示例
import { Pipe, PipeTransform } from '@angular/core';
import { DatePipe } from '@angular/common'
@Pipe({name: 'ifDate'})
export class IfDate implements PipeTransform {
private datePipe: DatePipe = new DatePipe();
transform(value: any, pattern?:string) : any {
if (typeof value === 'number') {return value}
try {
return this.datePipe.transform(value, pattern)
} catch(err) {
return value
}
}
}
热门推荐
8 送蛇的祝福语简短
10 团队文案祝福语简短励志
11 中秋快乐祝福语简短的
12 国庆简短幽默祝福语
13 妈妈给宝贝祝福语简短
14 高考送考祝福语简短
15 简短祝福语大全暖心
16 青春告白祖国简短祝福语
17 药店祝福语简短10字
18 喜事敬酒祝福语简短精辟