Here's what I'm trying to accomplish: I have a list and I want to display it without any duplicates. I attempted using the code (this.model.map(x => x.map), but it resulted in an error. Can anyone help me fix this?
model: myModel[];
myObj:any;
result:[];
constructor(){
this.result = Array.from(new Set(this.model.map(x => x.Name))); <----- I encountered an error with this line
`Cannot read properties of undefined (reading 'map')`
}
ngOninit(){
this.getList()
getList() {
this.services.getListAll(5, 1).subscribe((data: myModel[]) => {
this.myObj= data;
this.model= this.myObj.items
})
}
onPaginateChange(event: PageEvent ){
let index = event.pageIndex;
let size = event.pageSize;
index = index + 1;
this.services.getListAll(size, index).pipe(first()).subscribe((data: myModel[]) => {
this.myObj= data;
this.model= this.myObj.items
});
}
}
I've tried various approaches, but keep encountering the same error. Any assistance would be greatly appreciated.