2015-06-22 17:11:55 -07:00
|
|
|
import {isString, StringWrapper, CONST} from 'angular2/src/facade/lang';
|
2015-07-22 02:19:16 -07:00
|
|
|
import {Pipe, BasePipe, PipeFactory} from './pipe';
|
2015-06-26 00:22:06 +04:30
|
|
|
import {ChangeDetectorRef} from '../change_detector_ref';
|
2015-05-14 10:14:26 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements uppercase transforms to text.
|
|
|
|
*
|
|
|
|
* # Example
|
|
|
|
*
|
|
|
|
* In this example we transform the user text uppercase.
|
|
|
|
*
|
|
|
|
* ```
|
|
|
|
* @Component({
|
|
|
|
* selector: "username-cmp"
|
|
|
|
* })
|
|
|
|
* @View({
|
2015-05-18 02:58:13 -07:00
|
|
|
* template: "Username: {{ user | uppercase }}"
|
2015-05-14 10:14:26 -07:00
|
|
|
* })
|
|
|
|
* class Username {
|
2015-05-18 02:58:13 -07:00
|
|
|
* user:string;
|
2015-05-14 10:14:26 -07:00
|
|
|
* }
|
|
|
|
*
|
|
|
|
* ```
|
|
|
|
*/
|
2015-07-22 02:19:16 -07:00
|
|
|
@CONST()
|
|
|
|
export class UpperCasePipe extends BasePipe implements PipeFactory {
|
2015-07-07 20:03:00 -07:00
|
|
|
supports(str: any): boolean { return isString(str); }
|
2015-05-14 10:14:26 -07:00
|
|
|
|
2015-06-26 00:22:06 +04:30
|
|
|
transform(value: string, args: List<any> = null): string {
|
2015-07-22 02:19:16 -07:00
|
|
|
return StringWrapper.toUpperCase(value);
|
2015-05-14 10:14:26 -07:00
|
|
|
}
|
|
|
|
|
2015-07-22 02:19:16 -07:00
|
|
|
create(cdRef: ChangeDetectorRef): Pipe { return this; }
|
2015-05-14 10:14:26 -07:00
|
|
|
}
|