1
I will prefer to show first the error message you are giving.
error TS2349: Cannot invoke an Expression Whose type Lacks a call Signature. Type '((...items: any[]) => number) | (...items: Racaespecificotipo[]) => number)' has no compatible call Signatures.
This message appears immediately when I upload the Angular application. I will prefer to show you the code of how it was before and then how to show my attempt and then immediately tell my goal of my modification.
This is the data coming from the database:
0: {id: 1, Description: "Flounder", type: "Glkpo", type: "Fish"} 1: {id: 2, Description: "Scales", type: "GENERIC", typeAnimal: "Fish"} 2: {id: 3,... } 3: {id: 4, Description: "Bats", type: "GENERIC",... } 4: {id: 5, Description: "Scales", type: "GENERIC",... } 5: {id: 6, Description: "Dogs", type: "GENERIC", typeAnimal: "Mamiferos"} 6: {id: 7,... } 7: {id: 8, Description: "Put", type: "Glkpo",... } 8: {id: 9, Description: "Scales", type: "GENERIC", typeAnimal: "Fishes"} 9: {id: 10, Description: "Wolves", typeAnimal: "Mamiferos"} 10: {id: 11, Description: "Other", type: "OTHER", typeAnimal: "Fish"}
That is the entity in question:
export class RacaEspecificaTipo {
id: number;
descricao: string;
tipo: RascsEspecificoTipoEnum;
tipoAnimal: string;
}
This is the implementation before the modification:
loadTiposRacas(): void {
this.eventSubmitStart.emit();
this.service.getTiposRacas()
.pipe(catchError(this.handleErrorAndContinue([])))
.subscribe(tiposRacas => {
this.tiposRacas = tiposRacas;
this.eventSubmitDone.emit(false);
});
}
My goal is to put a filter on the list in such a way that it lists only records whose typohymal be only Pisces, I was not successful for lack of typescript skill, I do not know how it works with Arrays, when I did this mofificação as you can see below it generate error as shown at the beginning of this post. This code below was my attempt to filter the records.
loadTiposRacas(): void {
this.eventSubmitStart.emit();
this.service.getTiposRacas()
.pipe(catchError(this.handleErrorAndContinue([])))
.subscribe(tiposRacas => {
this.tipoRacas.filter(value => {
value.tipoAnimal === "Peixes"
tiposRacas.push(value);
});
this.eventSubmitDone.emit(false);
});
}
The variable typeRacas is being started through this variable below:
typRacas : Racaespecificotipo[] = [];
Please what modification could I perform on my code that could correct the error? The expected result should be this below;
0: {id: 1, Description: "Flounder", type: "Glkpo", type: "Fish"} 1: {id: 2, Description: "Scales", type: "GENERIC", typeAnimal: "Fish"} 2: {id: 3,... } 3: {id: 5, Description: "Scales", type: "GENERIC",... } 4: {id: 7,... } 5: {id: 8, Description: "Put", type: "Glkpo",... } 6: {id: 9, Description: "Scales", type: "GENERIC", typeAnimal: "Fishes"} 7: {id: 11, Description: "Other", type: "OTHER", typeAnimal: "Fish"}
This answers your question? Operation of Array.filter() in Javascript
– novic