我想为我的ionic2应用提供身份验证,所以我按照official documentation将其应用到全新的ionic2应用ionic start my_app blank
一旦我服务我的应用程序,这个错误就会触发:
Error: Can't resolve all parameters for Auth: (?).
at syntaxError (http://localhost:8100/build/main.js:107898:34)
at CompileMetadataResolver._getDependenciesMetadata (http://localhost:8100/build/main.js:121235:35)
at CompileMetadataResolver._getTypeMetadata (http://localhost:8100/build/main.js:121103:26)
at CompileMetadataResolver._getInjectableMetadata (http://localhost:8100/build/main.js:121089:21)
at CompileMetadataResolver.getProviderMetadata (http://localhost:8100/build/main.js:121379:40)
at http://localhost:8100/build/main.js:121308:49
at Array.forEach (<anonymous>)
at CompileMetadataResolver._getProvidersMetadata (http://localhost:8100/build/main.js:121269:19)
at CompileMetadataResolver.getNgModuleMetadata (http://localhost:8100/build/main.js:120924:50)
at JitCompiler._loadModules (http://localhost:8100/build/main.js:131988:66)
我已经 app.moodule.ts 在 app.moodule.ts 中注入了 Auth
import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
import { MyApp } from './app.component';
import { Auth } from '@ionic/cloud-angular';
@NgModule({
declarations: [
MyApp,
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
],
providers: [
StatusBar,
SplashScreen,
Auth,
{provide: ErrorHandler, useClass: IonicErrorHandler }
]
})
export class AppModule {}
根据我的研究,这个错误来自:
忘记用@Injectable()或@Inject(Auth)装饰Auth类
我试过注入:
@IonicPage()
@Component({
selector: 'page-home',
templateUrl: 'home.html',
})
@Injectable()
export class HomePage {........}
OR
export class HomePage {
constructor(@Inject(Auth) public auth: Auth) {
}
.......
}
但是这显示了同样的错误。
在我没有在app.module.ts中提供的Auth构造函数中具有依赖性
如您所见,我已经在我的代码中处理了这个案例。
循环依赖。
我真的认为这是问题,说实话,我知道如何检查这个,因为我还是初学者。
希望有人可以提供帮助