我想知道是否有人可以帮助我,我正在努力解决一个我在互联网上找不到任何痕迹的错误。它是“_co.auth未定义”,当我setRoot或推送到我的应用程序的主页时它被抛出。这是堆栈跟踪:
TypeError: _co.auth is undefined
Stack trace:
View_HomePage_0/<@ng:///AppModule/HomePage.ngfactory.js:56:21
debugUpdateDirectives@http://localhost:8100/build/vendor.js:13443:12
checkAndUpdateView@http://localhost:8100/build/vendor.js:12620:5
callViewAction@http://localhost:8100/build/vendor.js:12988:21
execComponentViewsAction@http://localhost:8100/build/vendor.js:12920:13
checkAndUpdateView@http://localhost:8100/build/vendor.js:12626:5
callViewAction@http://localhost:8100/build/vendor.js:12988:21
execEmbeddedViewsAction@http://localhost:8100/build/vendor.js:12946:17
checkAndUpdateView@http://localhost:8100/build/vendor.js:12621:5
callViewAction@http://localhost:8100/build/vendor.js:12988:21
execComponentViewsAction@http://localhost:8100/build/vendor.js:12920:13
checkAndUpdateView@http://localhost:8100/build/vendor.js:12626:5
callViewAction@http://localhost:8100/build/vendor.js:12988:21
execComponentViewsAction@http://localhost:8100/build/vendor.js:12920:13
checkAndUpdateView@http://localhost:8100/build/vendor.js:12626:5
callViewAction@http://localhost:8100/build/vendor.js:12988:21
execEmbeddedViewsAction@http://localhost:8100/build/vendor.js:12946:17
checkAndUpdateView@http://localhost:8100/build/vendor.js:12621:5
callViewAction@http://localhost:8100/build/vendor.js:12988:21
execComponentViewsAction@http://localhost:8100/build/vendor.js:12920:13
checkAndUpdateView@http://localhost:8100/build/vendor.js:12626:5
callWithDebugContext@http://localhost:8100/build/vendor.js:13843:39
debugCheckAndUpdateView@http://localhost:8100/build/vendor.js:13383:12
ViewRef_.prototype.detectChanges@http://localhost:8100/build/vendor.js:10546:9
ApplicationRef_.prototype.tick/<@http://localhost:8100/build/vendor.js:5169:58
ApplicationRef_.prototype.tick@http://localhost:8100/build/vendor.js:5169:13
next/<@http://localhost:8100/build/vendor.js:5041:100
M</l</t.prototype.invoke@http://localhost:8100/build/polyfills.js:3:14354
onInvoke@http://localhost:8100/build/vendor.js:4247:24
M</l</t.prototype.invoke@http://localhost:8100/build/polyfills.js:3:14281
M</c</r.prototype.run@http://localhost:8100/build/polyfills.js:3:9504
NgZone.prototype.run@http://localhost:8100/build/vendor.js:4178:54
next@http://localhost:8100/build/vendor.js:5041:70
EventEmitter.prototype.subscribe/schedulerFn<@http://localhost:8100/build/vendor.js:3992:36
SafeSubscriber.prototype.__tryOrUnsub@http://localhost:8100/build/vendor.js:27705:13
SafeSubscriber.prototype.next@http://localhost:8100/build/vendor.js:27652:17
Subscriber.prototype._next@http://localhost:8100/build/vendor.js:27592:9
Subscriber.prototype.next@http://localhost:8100/build/vendor.js:27556:13
Subject.prototype.next@http://localhost:8100/build/vendor.js:46504:17
EventEmitter.prototype.emit@http://localhost:8100/build/vendor.js:3978:54
checkStable@http://localhost:8100/build/vendor.js:4212:13
onLeave@http://localhost:8100/build/vendor.js:4291:5
onInvokeTask@http://localhost:8100/build/vendor.js:4241:17
M</l</t.prototype.invokeTask@http://localhost:8100/build/polyfills.js:3:14942
M</c</r.prototype.runTask@http://localhost:8100/build/polyfills.js:3:10195
M</h</e.invokeTask@http://localhost:8100/build/polyfills.js:3:16167
e/this.invoke@http://localhost:8100/build/polyfills.js:3:16049
n@http://localhost:8100/build/polyfills.js:2:31385
以下是我称之为的函数:
constructor(private toast: ToastController, private fb: FireBaseProvider, public navCtrl: NavController, public navParams: NavParams) {
}
createProfile(profile: Profile){
this.fb.createProfile(profile)
this.toast.create({
message: 'Profile information updated',
duration: 3000
}).present();
this.navCtrl.push(HomePage);
}
并且fb.createProfile另一端的函数是:
profile = {} as Profile;
user = {} as User;
constructor(private afAuth: AngularFireAuth, private afDatabase: AngularFireDatabase) {
}
createProfile(profile: Profile){
this.afAuth.authState.take(1).subscribe(auth => {
this.afDatabase.list(`profile/${auth.uid}`).push(this.profile);
});
}
我真的希望有人可以帮我解决这个问题因为我完全难过了!
提前致谢!