2016-09-21 82 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