2016-06-23 09:47:54 -07:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
|
*/
|
|
|
|
|
|
2016-06-08 16:38:52 -07:00
|
|
|
import {Pipe, PipeTransform} from '@angular/core';
|
2016-09-11 00:27:56 -07:00
|
|
|
import {isBlank} from '../facade/lang';
|
2016-08-25 00:50:16 -07:00
|
|
|
import {InvalidPipeArgumentError} from './invalid_pipe_argument_error';
|
2015-08-07 11:41:38 -07:00
|
|
|
|
2015-05-14 10:14:26 -07:00
|
|
|
/**
|
2016-09-08 21:41:09 -07:00
|
|
|
* @ngModule CommonModule
|
|
|
|
|
* @whatItDoes Transforms string to uppercase.
|
|
|
|
|
* @howToUse `expression | uppercase`
|
|
|
|
|
* @description
|
|
|
|
|
*
|
2016-10-31 12:39:21 +01:00
|
|
|
* Converts value into an uppercase string using `String.prototype.toUpperCase()`.
|
2015-05-14 10:14:26 -07:00
|
|
|
*
|
2015-10-19 15:37:32 +01:00
|
|
|
* ### Example
|
2015-05-14 10:14:26 -07:00
|
|
|
*
|
2016-09-08 21:41:09 -07:00
|
|
|
* {@example common/pipes/ts/lowerupper_pipe.ts region='LowerUpperPipe'}
|
2016-05-27 11:24:05 -07:00
|
|
|
*
|
2016-08-23 13:58:41 -07:00
|
|
|
* @stable
|
2015-05-14 10:14:26 -07:00
|
|
|
*/
|
2015-08-07 11:41:38 -07:00
|
|
|
@Pipe({name: 'uppercase'})
|
2015-08-12 12:04:54 -07:00
|
|
|
export class UpperCasePipe implements PipeTransform {
|
2016-04-22 15:33:32 -07:00
|
|
|
transform(value: string): string {
|
2015-08-06 10:39:02 -07:00
|
|
|
if (isBlank(value)) return value;
|
2016-09-11 00:27:56 -07:00
|
|
|
if (typeof value !== 'string') {
|
2016-08-25 00:50:16 -07:00
|
|
|
throw new InvalidPipeArgumentError(UpperCasePipe, value);
|
2015-08-06 10:39:02 -07:00
|
|
|
}
|
2015-10-31 13:04:26 -07:00
|
|
|
return value.toUpperCase();
|
2015-05-14 10:14:26 -07:00
|
|
|
}
|
|
|
|
|
}
|