StaticInjectorError(AppModule)[MsalGuard->路由器]

时间:2019-11-21 18:57:29

标签: angular microsoft-graph ionic4 angular-router msal

我已经使用ionic构建了一个webapp。我正在尝试将MSALModule导入我的应用程序。根据我在网上找到的教程等,您必须在app模块中添加以下内容:

MsalModule.forRoot({
      clientID: OAuthSettings.appId
    }),

当前,当我尝试转到使用它的页面时,它给了我以下错误。

We have a generic Error:  Error: Uncaught (in promise): Error: StaticInjectorError(AppModule)[MsalGuard -> Router]: 
  StaticInjectorError(Platform: core)[MsalGuard -> Router]: 
    NullInjectorError: No provider for Router!
Error: StaticInjectorError(AppModule)[MsalGuard -> Router]: 
  StaticInjectorError(Platform: core)[MsalGuard -> Router]: 
    NullInjectorError: No provider for Router!
    at _NullInjector.get (core.js:994)
    at resolveToken (core.js:1292)
    at tryResolveToken (core.js:1234)
    at StaticInjector.get (core.js:1102)
    at resolveToken (core.js:1292)
    at tryResolveToken (core.js:1234)
    at StaticInjector.get (core.js:1102)
    at resolveNgModuleDep (core.js:10847)
    at _createClass (core.js:10888)
    at _createProviderInstance$1 (core.js:10858)
    at c (polyfills.js:3)
    at Object.reject (polyfills.js:3)
    at NavControllerBase._fireError (nav-controller-base.js:223)
    at NavControllerBase._failed (nav-controller-base.js:216)
    at nav-controller-base.js:263
    at t.invoke (polyfills.js:3)
    at Object.onInvoke (core.js:4733)
    at t.invoke (polyfills.js:3)
    at r.run (polyfills.js:3)
    at polyfills.js:3

我没有导入路由模块,因为我未在应用程序中使用角(或离子)路由。有没有办法在不使用路由的情况下消除此错误?即我可以在不设置我的应用程序路由的情况下使用MSAL吗?

1 个答案:

答案 0 :(得分:1)

我看到您有导入语句...已添加到“提供者”部分:

{提供:HTTP_INTERCEPTORS,useClass:MsalInterceptor,多:true}

我的理解是,只要您拥有已开发的自定义提供程序,那不是绝对必要的。但是,如果不存在,则需要在提供程序部分中添加它。