0

In xyx.component.ts file I have 2 classes one is blot class which extends another class(Embed) which is provided by QuillJS(we shouldn't touch this). so inside the blot class i have to call a service but I am getting error Call target does not contain any signatures. this error is about super() ( i have added super() as my editor suggested to remove an error after creating constructor ) in the constructor even if I remove it I will get an error. I have searched on the internet for solutions. the internet has solutions for normal classes but not for Extends class. my goal is to call a service without any errors. so yes..any help is very much appreciated.

xyz.component.ts

class Blot extends Embed {
  some variables
       ..
       ..
  constructor(private myService:SomeService) { super() }
   foo () { 
      this.myService.someFun().subscribe(data => console.log(data) )
      }
  }

 export class XYZComponent implements Oninit {
     ...........
     some code
     ...........
  }
prem kumar
  • 101
  • 10

2 Answers2

0

There's a pending question here: how is your Blot instance created ?

If it is neither a component nor a service, then I assume you instantiate the class somewhere in your own code. If so, you cannot rely on the injector to provide the service, but you have to do it when you call the Blot constructor, like this:

export class XYZComponent  {
  ..
  // This is a component, so the service is provided by Angular injector
  constructor(private myService:SomeService) {
    ..
    // This is where the blot class is instantiated and the service is provided
    const blot = new Blot(this.myService);
    ..
  }
0

this post solved my problem. this is solved by writing the service inside the component class and exposing it to global space. so it will be accessed to outside classes as well.

prem kumar
  • 101
  • 10