我导入服务时出错,但我不明白为什么
import { CDService } from "../../services/definition";
constructor(
private toastyCommunicationService: ToastyCommunicationService,
private CDService : CDService,
private SharedService: SharedService,
private DatePipe: DatePipe
) { }
Run Code Online (Sandbox Code Playgroud)
我让我的服务很空洞,因为我对错误感到非常沮丧,不知道是什么导致了它.
export class CDService {
}
Run Code Online (Sandbox Code Playgroud)
现在我收到了错误
EXCEPTION: Uncaught (in promise): Error: DI Error
Error: DI Error
Run Code Online (Sandbox Code Playgroud)
我有两个问题:
1) DI错误到底是什么?
2)我该如何解决这个错误?
这是依赖注入错误.我认为你缺少@Injectable()装饰器:
@Injectable() // this line
export class CDService {
}
Run Code Online (Sandbox Code Playgroud)
编辑:
你有没有将CDService添加到NgModule中?
| 归档时间: |
|
| 查看次数: |
3083 次 |
| 最近记录: |