如何解决提供角度为 6
我们有一个抽象类
export declare abstract class APILoader {
abstract load(): Promise<void>;
}
在组件“CustomerComponent”中,它被注入到构造函数中,如
export class CustomerComponent implements OnInit {
constructor(public apiLoader : APILoader ) {}
}
CustomerLiteComponent 工作正常。这是现有的代码。所以现在我有了一个新特性,它使用了 CustomerComponent 的大部分功能。所以我在 CustomerLiteComponent 中扩展了 CustomerComponent 就像
export class CustomerLiteComponent extends CustomerComponent implements OnInit {
}
当我访问 CustomerLiteComponent 时,我收到
Error: Uncaught (in promise): Error: StaticInjectorError(AppModule)[CustomerLiteComponent -> APILoader]:
StaticInjectorError(Platform: core)[CustomerLiteComponent -> APILoader]:
NullInjectorError: No provider for APILoader!
我尝试添加
@Injectable({
providedIn: 'root'
})
用于 APILoader 并在应用程序模块提供程序中提供。但是错误没有修复。
请帮我解决这个问题。谢谢!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。