Angular 2 Pipes
|
currency
|
Supported
|
|
date
|
Supported
|
|
uppercase
|
Supported
|
|
json
|
Supported
|
|
limitTo
|
Supported
|
|
lowercase
|
Supported
|
|
number
|
Not
|
|
orderBy
|
Not
|
|
filter
|
Not
|
|
async
|
Supported
|
|
decimal
|
Supported
|
|
percent
|
Supported
|
| (pipe symbol)
|
Usage
|
expression | currency[:currencyCode[:symbolDisplay[:digitInfo]]]
|
|
currencyCode
|
ISO 4217 Compliant, eg USD, EUR
|
|
Usage
|
expression | date[:format]
|
|
Year
|
y or yy
|
|
Month
|
M or MM
|
|
Day
|
d or D
|
|
Weekday
|
EEE or EEEE
|
|
Hour
|
j or jj
|
|
Hour 12
|
h or hh
|
|
Hour 24
|
H or HH
|
|
Minute
|
m or mm
|
|
Second
|
s or ss
|
|
Timezone
|
z
|
|
Usage
|
item | uppercase
|
|
Usage
|
item | json
|
|
Usage
|
item| lowercase
|
|
Usage
|
item | async
|
|
Usage
|
expression | number[:digitInfo]
|
|
digit Info
|
{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}
|
|
Usage
|
expression | percent[:digitInfo]
|
|
see decimal for usage
|
import {Component, View, bootstrap, Pipe, PipeTransform} from 'angular2/angular2';
@Pipe({
name: 'tempConvert'
})
class TempConvertPipe implements PipeTransform {
transform(value: number, args: any[]) {
if(value && !isNaN(value) && args[0] === 'celsius') {
var temp = (value - 32) * 5/9;
var places = args[1];
return temp.toFixed(places) + ' C';
}
return;
}
}
|
import
|
import as normal
|
|
component usage
|
pipes: [ExponentialStrengthPipe]
|
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.