Store is quite simple:
Store
export const ContractStore = signalStore(
{providedIn: 'root'},
withState(initialState),
withComputed(({contracts, searchQuery}, ) => {
const contractService = inject(ContractService)
return {
sortedContracts: computed(() => {
const sortedContracts = contractService.sortContractsByFirstName(contracts())
})
return sortedContracts
}),
}
})
);
The service is quite large, but this is one of the functions inside it.
Service
public sortContractsByFirstName(contracts: Array<AnyContractDTO>): Array<AnyContractDTO> {
contracts.sort((a, b) => {
if (a.personalInformation.firstName.toLowerCase() < b.personalInformation.firstName.toLowerCase()) {
return -1;
} else if (a.personalInformation.firstName.toLowerCase() > b.personalInformation.firstName.toLowerCase()) {
return 1;
} else {
return 0;
}
});
return contracts
}
But I keep getting the error: ERROR TypeError: contractService.sortContractsByFirstName is not a function.
Does anyone know why this might be?