No provider for Angular service

I am trying to create a validator in my custom properties panel. The validator needs to check all keys in db to see if the workflow name (id) can be used (since this is the unique key). I am having a hard time injecting my Angular service, though i have read How to register custom service for injection - #3 by Etchelon
It seems no matter what i use, value, factory, or type, it then complains about the service’s constructor items not having a provider, so i add workflowRepo, then it wants a provider for http…etc.

export default {
    __init__: [ 

        'router',
        'handler',
        'apiService',
        'workFlowRepo',
        'workflowService'
    ],

    router: ['type', Router],
    handler: ['type', HttpHandler],
    http: ['type', HttpClient],
    apiService: ['type', APIService],
    workflowRepo: ['type', WorkflowRepo],
    workflowService: ['type', WorkflowService]
  };

how I am using in properties provider:

    static $inject = [
        'camundaPropertiesProvider',
        'workflowService'
    ];

    constructor (
        private camundaPropertiesProvider,
        private workflowService
    ) {

Please share a running / prototypical example that clearly shows what you’re trying to achieve, what is working and what is not.

Use our existing starter projects to quickly hack it or share your existing, partial solution on GitHub or via a CodeSandbox. Provide the necessary pointers that allow us to quickly understand where you got stuck.

This way we may be able to help you in a constructive manner.

Thanks :heart:

Thank you, was able to inject it this way :
{ workflowService: ['value', this.workflowService] },
and then I did a bind in the services constructor like

constructor(private workflowRepo: WorkflowRepo) {

        this.getDiagram = this.getDiagram.bind(this);

    }

In this way I am now able to check if that diagram id already exists and throw a validation error if it does.

1 Like