TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Dev Teywa
NA
250
40.6k
how to avoid display redundancy of result in typescript
Feb 7 2018 10:03 AM
hi,
i have problem in each click on the button it returns to me the result I want after the click and show me result after the inputs will be emptied it shows me nothing
here is a descriptive picture of the problem
app.component.ts
import { Component,OnInit } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent
{
firstdate:Date;
lastdate:Date;
filterdata:any;
dateCheck(fDate:Date,lDate:Date)
{
if(this.projetList && this.projetList.length)
{
this.projetList.forEach((proj :any) =
>
{
if (proj.datedeb
>
=fDate && proj.datefin
<
=lDate)
{
this.filterdata.push(proj);
}
});
}
return this.filterdata;
}
projetList:any;
constructor()
{
this.filterdata
=[];
this.projetList
=[
{name:"maroua",lastname:"oumlaz",datedeb:"2015-10-10",datefin:"2016-02-02"},
{name:"yassine",lastname:"oumlaz",datedeb:"2017-11-23",datefin:"2018-01-01"}
];
}
ngOnInit()
{
/*if (
this.globals.user
=== '' ||
this.globals.user
=== null)
{
this.route.navigateByUrl('login/login');
}*/
}
}
app.component.html
<
html
>
<
head
>
<
title
>
Date before current date
</
title
>
</
head
>
<
body
>
<
h2
>
Check if date is between two dates
</
h2
>
Enter first Date(dd/mm/yyyy):
<
input
type
=
"date"
name
=
"fDate"
#firstdate
/>
<
br
/>
Enter second Date(dd/mm/yyyy):
<
input
type
=
"date"
name
=
"lDate"
#lastdate
/>
<
br
/>
<
input
type
=
"submit"
value
=
"Check"
(click)="dateCheck(firstdate.value,lastdate.value);"
/>
<
p
*
ngFor
=
"let pr of filterdata"
>
{{pr.name}}
</
p
>
</
body
>
</
html
>
Reply
Answers (
1
)
filter ,date pipe using angular2
how to implement earning point in website using Angular2+