我是离子应用程序开发人员的新手,我面临着这个问题:当我打开一个组件时,它会显示错误消息,即cannot use namespace as type ionic(NgZone,NavController and googlePlus)
。为什么会收到此错误消息?
这是我的代码:
export class HomePage {
userProfile: any = null;
zone: NgZone;
constructor(public navCtrl: NavController, private googlePlus: GooglePlus) {
this.zone = new NgZone({});
firebase.auth().onAuthStateChanged( user => {
this.zone.run( () => {
if (user){
this.userProfile = user;
} else {
this.userProfile = null;
}
});
});
}
}
答案 0 :(得分:0)
尝试以下代码:( NgZone对象可以如下创建)
export class HomePage {
userProfile: any = null;
zone: NgZone;
constructor(public navCtrl: NavController, private googlePlus: GooglePlus, private ngZone: NgZone) {
this.zone = ngZone;
firebase.auth().onAuthStateChanged( user => {
this.zone.run( () => {
if (user){
this.userProfile = user;
} else {
this.userProfile = null;
}
});
});
}
}
答案 1 :(得分:0)
也许你忘了更新项目的包。请尝试:
npm install / npm update