I have two classes like this
export interface ClosureSummary {
Domain: string;
DomainCode: string;
FundingDomain: string;
FundingDomainCode: string;
ProjectManager: string;
ProjectManagerCode: string;
PipelineOwner: string;
PipelineOwnerCode: string;
ProjectCode: string;
ProjectName: string;
ProjectType: string;
LifeCycle: string;
Framework: string;
ProjectEndDate: Date;
Financials: number;
Forecast: number;
Risk: number;
AR2: number;
ClosureCertificate: number;
ClosureType: string;
Milestone: number;
Artefacts: number;
Issue: number;
PEPIC: number;
}
export interface MultiselectItem{
{
id: string;
name: string;
}
Here the second smaller interface is just for dropdown controls for which the data being filtered from the main class without any duplicate.
So I did a function like this
closureDomains:MultiselectItem[]=[];
clSummary:ClosureSummary[]=[];
//here getting data into clsummary
..
this.closureDomains = res.map((x) =>{ return { id:x.DomainCode,name:x.Domain};}).filter(function (elem, index, self) {
return index === self.indexOf(elem)
});
So the closureDomains array now contains DomainCode and DomainName correctly, but with duplicates.
I think my filter part not working correctly.
Please share your thoughts.