简体   繁体   中英

Angular2 calling a service from another service

I have 2 services - 1/Files and 2/FTPClient in angular2.

They are Singleton services - and work perfectly when injected into a component through its constructor like this :

constructor(public filesIn:Files, public ftpIn:FTPClient){}

SO now I would like to use the Files server within the FTPClient itself...so I try the same thing. This is my code for the constructor of the FTPClient service:

constructor(public filesIn:Files) {
        this.files = filesIn;
    }

But this throws the error:

Can't resolve all parameters for FTPClient (?)

My application only has one module - and both the Files and FTPClient are in the providers list :

 providers: [APIData,FTPClient,Files,SSHClient, WINDOW_PROVIDER]

Please can you shed some light on what I am doing wrong here!

我必须在类开始的上方添加@Injectable()装饰器-并通过添加以下@Injectable() Injectable导入文件:

import { Injectable } from '@angular/core';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM