我想用这样的东西:
猫接口.ts
export interface ICats {
meow(): void
}
Run Code Online (Sandbox Code Playgroud)
猫服务.ts
@Injectable()
export class CatsService implements ICats {
constructor()
meow(): void {
return;
}
}
Run Code Online (Sandbox Code Playgroud)
猫模块.ts
@Module({
providers: [CatsService]
exports: [CatsService]
})
export class CatsModule {}
Run Code Online (Sandbox Code Playgroud)
动物.service.ts
@Injectable()
export class AnimalsService {
constructor(@Inject('ICats') private readonly cats: ICats)
test(): void {
return this.cats.meow();
}
}
Run Code Online (Sandbox Code Playgroud)
动物模块.ts
@Module({
imports: [CatsModule],
providers: [AnimalsService],
exports: [AnimalsService]
Run Code Online (Sandbox Code Playgroud)
但收到
Nest can't resolve dependencies of the