Error "Can't resolve all parameters for provider"

I got an error Can't resolve all parameters for OneProvider: ([object Object], [object Object], ?),

When import provider from both side.

First one.

import { Injectable } from '@angular/core';
import { TwoProvider } from '../two/two';

@Injectable()
export class OneProvider {
  constructor(private two: TwoProvider) {}
}

Other one.

import { Injectable } from '@angular/core';
import { OneProvider } from '../one/one';

@Injectable()
export class TwoProvider {
  constructor(private one: OneProvider) {}
}

What can I do?

1 Like

Can you show the code where you use the providers?

You have circular dependency: https://stackoverflow.com/questions/36378751/angular2-2-services-depending-on-each-other

2 Likes
import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { TwoProvider } from '../providers/two/two'

@Component({
  templateUrl: 'app.html'
})
export class MyApp {

  rootPage:any;

  constructor(
    private platform: Platform, private statusBar: StatusBar, private splashScreen: SplashScreen,
    private two: TwoProvider
  ) {
    this.platform.ready().then(() => {

      this.two.methodOne()
      .then(data => {

        this.two.methodTwo()
        .then(data => {

          // Do something

        })
        .catch(error => {

            // Do something

        });

      })
      .catch(error => {
        // Do something
      });

    });
  }
}

@MattE Please help me with the link: