【发布时间】:2020-05-19 15:51:26
【问题描述】:
如何解决以下错误
AppComponent.html:9 ERROR Error: StaticInjectorError(AppModule)[OzaAuthService -> InjectionToken oza.config.angular]:
StaticInjectorError(Platform: core)[OzaAuthService -> InjectionToken oza.config.angular]:
NullInjectorError: No provider for InjectionToken oza.config.angular!
AuthService.ts :在 AuthService 中调用自定义“oza 包”。
import { OzaAuthService } from '@oza/oza-angular';
@Injectable({
providedIn: 'root'
})
export class AuthService {
_accessToken: string;
constructor(private ozaAuthService: OzaAuthService) {
console.log('ozaAuthService');
this.$getAccessToken().subscribe(token => {
this._accessToken = token;
});
}
public getAccessToken(): string {
return this._accessToken;
}
在 App.module.ts 中导入 oza 包并在 provider 中添加 OzaAuthService 但仍然报错。
import { OzaAuthService} from '@oza/oza-angular';
@NgModule({
declarations: [
AppComponent,
],
imports: [
imports: [
BrowserModule,
NgbModule,
// router
RouterModule.forRoot(routes),
StoreModule.forRoot({}),
})
],
exports: [
HttpClientModule
],
providers: [
**OzaAuthService**
],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
bootstrap: [AppComponent]
})
export class AppModule {}
【问题讨论】:
-
有什么更新吗?看我的回答
标签: angular angular-ui-router node-modules