0
루트 세그먼트 경로를 사용하는 구성 요소에 다음 코드가 있습니다.TypeError : 각도 2 약속에서 정의되지 않은 'then'속성을 읽을 수 없습니다.
ngOnInit() {
...
this.route.queryParams.forEach((params: Params) => {
if (params['scrollTo']) {
this.checkIfDataLoaded().then(() => {
this.scrollToSection(params['scrollTo']);
})
}
});
}
checkIfDataLoaded() {
if (this.firstLoaded && this.secondLoaded && this.thirdnLoaded) {
return new Promise((resolve, reject) => {
resolve(true);
});
}
}
내가 저점 경로를 전환 내 루트 세그먼트에 돌아올 때까지 잘 작동, 난이 오류를 얻을 디버거를 발견
TypeError: Cannot read property 'then' of undefined
at eval (http://localhost:54396/app/my.component.js:58:42)
at SafeSubscriber.eval [as _next] (http://localhost:54396/node_modules/rxjs/Observable.js:108:21)
at SafeSubscriber.__tryOrSetError (http://localhost:54396/node_modules/rxjs/Subscriber.js:232:16)
at SafeSubscriber.next (http://localhost:54396/node_modules/rxjs/Subscriber.js:174:27)
at Subscriber._next (http://localhost:54396/node_modules/rxjs/Subscriber.js:125:26)
at Subscriber.next (http://localhost:54396/node_modules/rxjs/Subscriber.js:89:18)
at BehaviorSubject._subscribe (http://localhost:54396/node_modules/rxjs/BehaviorSubject.js:28:24)
at BehaviorSubject.Observable.subscribe (http://localhost:54396/node_modules/rxjs/Observable.js:56:27)
at eval (http://localhost:54396/node_modules/rxjs/Observable.js:87:38)
at new ZoneAwarePromise (http://localhost:54396/node_modules/zone.js/dist/zone.js:467:29)
일이 어떻게이 문제를 해결하는 것입니다 어떤 생각 ? checkIfDataLoaded
는 약속을 반환하지 않는 경우
, 내 약속 로직을 간다, 명확하게 주셔서 감사합니다 –