I have a service which fetches the data object from the server. There is another class which is a general utility class. It has a static method in which i want to use service instance. but due to method being static this wont work. example code:
export class DataUtil {
constructor(public core:CoreStructureService){
}
static fetchContact(id:string):ContactModel{
for(let contact of this.core.contactList){
if(contact.contactId == id)
return contact
}
}
}
This will not compile as the line this.core.contactList in the for stmt is not valid. being method static i cannot refer core as this.core. So how do i fix this.
fetchContactstatic?genericmethod per se. It's a generalized method probably.