按开始日期和结束日期在angular2 +中过滤详细信息 [英] Filter details by start date and end date in angular2+
本文介绍了按开始日期和结束日期在angular2 +中过滤详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi,
I want to filter some details by start date and end date
PS: i have array in component contains details and start date and end date
i created this pipe but it doesn't work
how to do please
and thanks in advance
我尝试过:
What I have tried:
import { Pipe, PipeTransform } from '@angular/core';
import { DatePipe } from '@angular/common';
@Pipe({
name: 'dateFormatPipe',
})
export class dateFormatPipe implements PipeTransform {
transform(projetList:any,value1: string,value2: string) {
if (projetList && projetList.length)
{
var datePipe = new DatePipe("en-US");
value1= datePipe.transform(value1, 'dd/MM/yyyy');
value2= datePipe.transform(value2, 'dd/MM/yyyy');
projetList.forEach(proj => {
if (value1 >= value2)
{
return proj.title;
}
});
}
else
{
return projetList;
}
}
}
推荐答案
看一看在此: javascript - 两个日期AngularJS之间的自定义过滤器 - 堆栈溢出 [ ^ ]
对于我(我不是Angular专家),你必须添加另一部分条件:
Take a look at this: javascript - Custom filter between two dates AngularJS - Stack Overflow[^]
As to me (i'm not Angular expert), you have to add another part of condition:
projetList.forEach(proj => {
if (proj.ComparedDate >=value1 && proj.ComparedDate<=value2)
{
return proj.title;
}
详情请见:
轻松实现:日期过滤和格式化g在Angular 2中使用管道 [ ^ ]
轻松一点:Angular js中的日期过滤和格式化。 [ ^ ]
这篇关于按开始日期和结束日期在angular2 +中过滤详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文