Files
Angular-Docs-Cn/modules/@angular/common/src/pipes/lowercase_pipe.ts
T

24 lines
655 B
TypeScript
Raw Normal View History

2016-06-03 12:40:41 +02:00
import {PipeTransform, Pipe} from '@angular/core';
2016-05-31 15:22:59 -07:00
import {isString, isBlank} from '../facade/lang';
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
/**
* Transforms text to lowercase.
*
* ### Example
*
* {@example core/pipes/ts/lowerupper_pipe/lowerupper_pipe_example.ts region='LowerUpperPipe'}
*
* @experimental
*/
@Pipe({name: 'lowercase'})
2015-08-12 12:04:54 -07:00
export class LowerCasePipe implements PipeTransform {
transform(value: string): string {
if (isBlank(value)) return value;
if (!isString(value)) {
throw new InvalidPipeArgumentException(LowerCasePipe, value);
}
return value.toLowerCase();
}
}