1. 程式人生 > >angular4自定義根據日期判斷星期的管道

angular4自定義根據日期判斷星期的管道

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 ;         }     } }