简体   繁体   English

未捕获(承诺):错误:没有 GooglePlus 的提供者

[英]Uncaught (in promise): Error: No provider for GooglePlus

I am trying to use the cordova-plugin-googleplus plugin.我正在尝试使用cordova-plugin-googleplus插件。

I have read the other posts that say to add the plugin as a provider, and have tried to do that to no avail.我已经阅读了其他帖子,说要将插件添加为提供程序,但尝试这样做无济于事。

When I try to visit my login page I get this error with stack trace:当我尝试访问我的登录页面时,堆栈跟踪出现此错误:

Runtime Error Uncaught (in promise): Error: No provider for GooglePlus: Error: No provider for GooglePlus!未捕获运行时错误(承诺):错误:GooglePlus 没有提供程序:错误:GooglePlus 没有提供程序! at injectionError ( http://localhost:8100/build/vendor.js:1590:86 ) at noProviderError ( http://localhost:8100/build/vendor.js:1628:12 ) at ReflectiveInjector_.在 injectionError ( http://localhost:8100/build/vendor.js:1590:86 ) 在 noProviderError ( http://localhost:8100/build/vendor.js:1628:12 ) 在 ReflectiveInjector_。 throwOrNull ( http://localhost:8100/build/vendor.js:3129:19 ) at ReflectiveInjector . throwOrNull ( http://localhost:8100/build/vendor.js:3129:19 ) 在 ReflectiveInjector getByKeyDefault ( http://localhost:8100/build/vendor.js:3168:25 ) at ReflectiveInjector . getByKeyDefault ( http://localhost:8100/build/vendor.js:3168:25 ) 在 ReflectiveInjector getByKey ( http://localhost:8100/build/vendor.js:3100:25 ) at ReflectiveInjector .get ( http://localhost:8100/build/vendor.js:2969:21 ) at AppModuleInjector.get (ng:///AppModule/module.ngfactory.js:332:145) at AppModuleInjector.getInternal (ng:///AppModule/module.ngfactory.js:615:44) at AppModuleInjector.NgModuleInjector.get ( http://localhost:8100/build/vendor.js:3936:44 ) at LoginPageModuleInjector.NgModuleInjector.get ( http://localhost:8100/build/vendor.js:3937:52 ) getByKey ( http://localhost:8100/build/vendor.js:3100:25 ) 在 ReflectiveInjector .get ( http://localhost:8100/build/vendor.js:2969:21 ) 在 AppModuleInjector.get (ng: ///AppModule/module.ngfactory.js:332:145) 在 AppModuleInjector.getInternal (ng:///AppModule/module.ngfactory.js:615:44) 在 AppModuleInjector.NgModuleInjector.get ( http://localhost: 8100/build/vendor.js:3936:44 ) 在 LoginPageModuleInjector.NgModuleInjector.get ( http://localhost:8100/build/vendor.js:3937:52 )

Stacktrace堆栈跟踪

Error: Uncaught (in promise): Error: No provider for GooglePlus!
Error: No provider for GooglePlus!
    at injectionError (http://localhost:8100/build/vendor.js:1590:86)
    at noProviderError (http://localhost:8100/build/vendor.js:1628:12)
    at ReflectiveInjector_._throwOrNull (http://localhost:8100/build/vendor.js:3129:19)
    at ReflectiveInjector_._getByKeyDefault (http://localhost:8100/build/vendor.js:3168:25)
    at ReflectiveInjector_._getByKey (http://localhost:8100/build/vendor.js:3100:25)
    at ReflectiveInjector_.get (http://localhost:8100/build/vendor.js:2969:21)
    at AppModuleInjector.get (ng:///AppModule/module.ngfactory.js:332:145)
    at AppModuleInjector.getInternal (ng:///AppModule/module.ngfactory.js:615:44)
    at AppModuleInjector.NgModuleInjector.get (http://localhost:8100/build/vendor.js:3936:44)
    at LoginPageModuleInjector.NgModuleInjector.get (http://localhost:8100/build/vendor.js:3937:52)
    at c (http://localhost:8100/build/polyfills.js:3:13535)
    at Object.reject (http://localhost:8100/build/polyfills.js:3:12891)
    at NavControllerBase._fireError (http://localhost:8100/build/vendor.js:45902:16)
    at NavControllerBase._failed (http://localhost:8100/build/vendor.js:45890:14)
    at http://localhost:8100/build/vendor.js:45945:59
    at t.invoke (http://localhost:8100/build/polyfills.js:3:9283)
    at Object.onInvoke (http://localhost:8100/build/vendor.js:4508:37)
    at t.invoke (http://localhost:8100/build/polyfills.js:3:9223)
    at r.run (http://localhost:8100/build/polyfills.js:3:4452)
    at http://localhost:8100/build/polyfills.js:3:14076

Platform details平台详情

  • Ionic Framework: 3.6.1离子框架:3.6.1
  • Ionic App Scripts: 2.1.4离子应用程序脚本:2.1.4
  • Angular Core: 4.1.3 Angular 核心:4.1.3
  • Angular Compiler CLI: 4.1.3 Angular 编译器 CLI:4.1.3
  • Node: 6.11.2节点:6.11.2
  • OS Platform: Windows 10操作系统平台:Windows 10
  • Navigator Platform: Win32 User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36导航器平台:Win32 用户代理:Mozilla/5.0(Windows NT 10.0;Win64;x64)AppleWebKit/537.36(KHTML,如 Gecko)Chrome/60.0.3112.113 Safari/537.36

Login.ts登录.ts

import { Component } from '@angular/core';
//import { GooglePlus } from '@ionic-native/google-plus';
import { TranslateService } from '@ngx-translate/core';
import { IonicPage, NavController, ToastController } from 'ionic-angular';

import { User } from '../../providers/providers';
import { MainPage } from '../pages';

@IonicPage()
@Component({
  selector: 'page-login',
  templateUrl: 'login.html'
})
export class LoginPage {
  // The account fields for the login form.
  // If you're using the username field with or without email, make
  // sure to add it to the type
  account: { username: string, password: string } = {
    username: '',
    password: ''
  };

  // Our translated text strings
  private loginErrorString: string;

  constructor(public navCtrl: NavController,
    public user: User,
    public toastCtrl: ToastController,
    public translateService: TranslateService,
//    private GooglePlus: GooglePlus
  ) {

    this.translateService.get('LOGIN_ERROR').subscribe((value) => {
      this.loginErrorString = value;
    })
  }

  // Attempt to login in through our User service
  doLogin() {
    this.user.login_basic(this.account).subscribe((resp) => {
      this.navCtrl.push(MainPage);
    }, (err) => {
      this.navCtrl.push(MainPage);
      // Unable to log in
      let toast = this.toastCtrl.create({
        message: this.loginErrorString,
        duration: 3000,
        position: 'top'
      });
      toast.present();
    });
  }

}

login.module.ts登录模块.ts

import { NgModule } from '@angular/core';
import { GooglePlus } from '@ionic-native/google-plus';
import { TranslateModule } from '@ngx-translate/core';
import { IonicPageModule } from 'ionic-angular';

import { LoginPage } from './login';

@NgModule({
  declarations: [
    LoginPage,
  ],
  imports: [
    IonicPageModule.forChild(LoginPage),
    TranslateModule.forChild()
  ],
  exports: [
    LoginPage
  ],
  providers: [
    GooglePlus,
  ],
})
export class LoginPageModule { }

您需要将GooglePlus提供程序添加到AppModule(app.module.ts)

Adding GooglePlus to the App.module.ts worked for me将 GooglePlus 添加到the App.module.ts对我有用

@NgModule({

  ...

  providers: [
    
    GooglePlus,
    
    
  ],
  bootstrap: [AppComponent]
})

In case of the Angular, GooglePlus should be imported like this (app.module.ts):在 Angular 的情况下,应像这样导入GooglePlus (app.module.ts):

import { GooglePlus } from '@ionic-native/google-plus/ngx';

...

providers: [  
    GooglePlus,  
]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:未捕获(承诺中):未处理的承诺拒绝 - Error: Uncaught (in promise): Unhandled promise rejections 如何解决未捕获(承诺)错误? - how to solve Uncaught (in promise) error? Uncaught Promise错误:TypeError:member不是函数 - Uncaught Promise Error: TypeError: member is not a function Uncaught (in promise) TypeError: Failed to fetch and Cors error - Uncaught (in promise) TypeError: Failed to fetch and Cors error 未捕获的错误:[$ injector:unpr]未知提供程序:sessionInjectorProvider - Uncaught Error: [$injector:unpr] Unknown provider: sessionInjectorProvider 动态导入组件错误-未捕获(承诺)错误:找不到模块 - Dynamic import components error - Uncaught (in promise) Error: Cannot find module 出现错误:未捕获(承诺):状态为404的URL找不到响应: - Getting Error: Uncaught (in promise): Response with status: 404 Not Found for URL: Axios - 未捕获(承诺)错误:请求失败,状态码为 500 - Axios - Uncaught (in promise) Error: Request failed with status code 500 未捕获(承诺)错误:请求失败,状态码为500 - Uncaught (in promise) Error: Request failed with status code 500 错误未捕获(承诺中)TypeError:无法读取未定义的属性“记录集” - error Uncaught (in promise) TypeError: Cannot read property 'recordset' of undefined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM