Angular 自定义管道

阅读 105

2022-07-04

//组件
export class AppComponent {
title = 'my-App';
msg = 'yqq';
}
//自定义管道
import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
name: 'lcUppercase'
})
export class LcUppercasePipe implements PipeTransform {

transform(value: string, ...args :string[]): string {
if(value == 'yqq'){
return value.toUpperCase()+'大帅哥';
}
return 'yyds';
}
}
/*视图*/
<h1>{{msg|lcUppercase}}</h1>

Angular 自定义管道_html


精彩评论(0)

0 0 举报