不能使用命名空间 'NavController'',NgZone',Google 作为类型
Cannot use namespace 'NavController'',NgZone',Google,as a type
我是 ionic app developer 的新手,我遇到了这个问题:当我打开一个组件时,它显示错误消息,即 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;
}
});
});
}
}
试试下面的代码:(可以按如下方式创建 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;
}
});
});
}
}
也许您忘记更新项目的包。请尝试:
npm install / npm update
我是 ionic app developer 的新手,我遇到了这个问题:当我打开一个组件时,它显示错误消息,即 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;
}
});
});
}
}
试试下面的代码:(可以按如下方式创建 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;
}
});
});
}
}
也许您忘记更新项目的包。请尝试:
npm install / npm update