angular4自定义根据日期判断星期的管道

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/friend_ship/article/details/78889895
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 ;
        }
    }
}

猜你喜欢

转载自blog.csdn.net/friend_ship/article/details/78889895