错误错误:未捕获(承诺中):NullInjectorError:R3InjectorError(AppModule)

问题描述 投票:0回答:1

[[有service.ts、app.module.ts、错误enter image description here](https://i.stack.imgur.com/kyR2D.png)](https://i.stack.imgur.com/JvKcm.png)

我有这个问题。我尝试在提供者中导入服务(在可注入中没有提供),在 app.module.ts 中导入 HttpClientModule,在 @Injectable 中使用providIn:'root',并且错误仍然存在。你知道我能做什么吗?

angular service
1个回答
0
投票

您需要将装饰器 Injectable 放在类旁边(本例的服务)

@Injectable({
    providedIn: ‘root’
})
export class RegisterService {…}
© www.soinside.com 2019 - 2024. All rights reserved.