mercredi 25 novembre 2020

EmberJS: Injecting owner to native class from component

The thing i'm trying to do, is to inject owner to my JS native class in Ember(3.15.0). It looks something like this:

  component.ts

  export default class ClassOne extends Component {
    constructor() {
      super(...arguments);
      const myClass = new ClassTwo();
      ...
    }
  }

  ClassTwo.ts

  export default class ClassTwo {
    @service() someService: ServiceType;
    ...
  }
  

Because of that, on someService, i'm getting expectable Attempting to lookup an injected property on an object without a container, ensure that the object was instantiated via a container

I've seen similar questions that were solved by using getOwner(this).ownerInjection() but those were all based on Class.create() that was extended by Ember.Object.

Is there any way to do that?

Thanks in advance for any help.




Aucun commentaire:

Enregistrer un commentaire