2016-09-21 45 views
2

我成立了Ionic Cloud Service並完成了授權用戶的初始過程。原始異常:沒有Auth提供程序! :Ionic Cloud服務

import {Component} from '@angular/core'; 
import {NavController} from 'ionic-angular'; 
import {Auth, User, UserDetails, IDetailedError} from '@ionic/cloud-angular'; 

@Component({ 
    templateUrl: 'build/pages/signup/signup.html' 
}) 
export class SignupPage { 

    constructor(public auth: Auth, public user: User){ 
    let details: UserDetails = {'email': '[email protected]', 'password': 'puppies123'}; 

    this.auth.signup(details).then(() => { 
     // `this.user` is now registered 
    }, (err: IDetailedError<string[]>) => { 
     for (let e of err.details) { 
     if (e === 'conflict_email') { 
      alert('Email already exists.'); 
     } else { 
      // handle other errors 
     } 
     } 
    }); 
    } 

} 

由於某種原因,我收到此錯誤:原始異常:沒有Auth提供程序! ORIGINAL堆棧跟蹤: 錯誤:DI異常

一切都設置像離子云文檔三通提示:https://docs.ionic.io/services/auth/#setup

我到處找這個答案

+0

我給github添加了一個問題:https://github.com/driftyco/ionic-cloud-issues/issues/219 –

回答

4

在它談論如何將離子云NgModule添加到您的模塊的進口設置說明:

https://docs.ionic.io/setup.html

import { CloudSettings, CloudModule } from '@ionic/cloud-angular'; 

const cloudSettings: CloudSettings = { 
    'core': { 
    'app_id': 'APP_ID' 
    } 
}; 

@NgModule({ 
    declarations: [ ... ], 
    imports: [ 
    IonicModule.forRoot(MyApp), 
    CloudModule.forRoot(cloudSettings) 
    ], 
    bootstrap: [IonicApp], 
    entryComponents: [ ... ], 
    providers: [ ... ] 
}) 
export class AppModule {} 

我錯過了這些步驟。進行此更改可解決問題。

0

試試這個

@Component({ 
    templateUrl: 'build/pages/signup/signup.html', 
    providers: [Auth] 
}) 

不確定它是否有效,因爲離子文檔沒有對此提出任何說明,但看​​起來似乎符合您的錯誤

+0

如果我嘗試這個,我會得到「Can not read property'config'undefined」正如下面的Helder所提到的。 –

+0

不要這樣做。 Ionic Cloud客戶端需要全面指定爲「導入」的NgModule,而不是通過提供者逐案指定。請參閱我們的設置文檔:http://docs.ionic.io/setup.html – dwieeb

+0

請更新您的文檔,截至開始使用Ionic Cloud之前,我們希望您熟悉:'並不意味着:'爲了這個框架像預期的那樣工作,你必須使用:'' – Ivaro18

0

providers傳遞Auth,開始出現在控制檯錯誤:

Cannot read property 'config' of undefined 
相關問題