angular4自定義根據日期判斷星期的管道
阿新 • • 發佈:2018-12-06
import
{
Pipe
,
PipeTransform
}
from
'@angular/core'
;
@ Pipe ({ name: 'formatDay' })
export class FormatDayPipe
implements
PipeTransform
{
transform
(
value
:
any
):
any
{
if
(
value
!==
undefined
) {
let
weekArray
=
new
Array
(
'週日'
,
'週一'
,
'週二'
,
'週三'
,
'週四'
,
'週五'
,
'週六'
);
let
myDate
=
new
Date
(
value
);
let
week
=
weekArray
[
myDate
.
getDay
()];
return
week
;
}
}
}
@ Pipe ({ name: 'formatDay' })
export class FormatDayPipe