我正在尝试为我的ionic 4应用程序插入Google登录功能,但每次我点击登录按钮时都会出现问题,就像这样:
。
![have a problem like this](https://istack.dev59.com/Bla9e.webp)
Cannot access 'LoginPageModule' before initialization
我的 login.page.ts 代码看起来像这样
import { Component, OnInit } from '@angular/core';
import { NavController } from '@ionic/angular';
import { GooglePlus } from '@ionic-native/google-plus';
@Component({
selector: 'app-login',
templateUrl: './login.page.html',
styleUrls: ['./login.page.scss'],
})
export class LoginPage{
displayName: any;
email: any;
familyName: any;
givenName: any;
userId: any;
imageUrl: any;
isLoggedIn:boolean = false;
constructor(
public navCtrl: NavController,
public googlePlus: GooglePlus
) { }
login() {
this.googlePlus.login({})
.then(res => {
console.log(res);
this.displayName = res.displayName;
this.email = res.email;
this.familyName = res.familyName;
this.givenName = res.givenName;
this.userId = res.userId;
this.imageUrl = res.imageUrl;
this.isLoggedIn = true;
})
.catch(err => console.error(err));
}
logout() {
this.googlePlus.logout()
.then(res => {
console.log(res);
this.displayName = "";
this.email = "";
this.familyName = "";
this.givenName = "";
this.userId = "";
this.imageUrl = "";
this.isLoggedIn = false;
})
.catch(err => console.error(err));
}
ngOnInit() {
}
}
我尝试了不同的方法,但仍然出现这个错误,有人知道如何解决吗?
这是login.module.ts文件,我之前没有修改过它,但LoginPageModule在这里,所以问题可能出自这里?
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { Routes, RouterModule } from '@angular/router';
import { IonicModule } from '@ionic/angular';
import { LoginPage } from './login.page';
const routes: Routes = [
{
path: '',
component: LoginPage
}
];
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
RouterModule.forChild(routes)
],
declarations: [LoginPage]
})
export class LoginPageModule {}