0
최근 Angular 2에서 Angular 5로 업그레이드했으며 AngularFireAuth 패키지도 업데이트했습니다. 알아낼 수있다.Angular 및 AngularFireAuth를 업그레이드 한 후 '지도가 함수가 아닙니다'오류가 발생했습니다.
아래의 .map을 사용하여 컴파일 오류가 발생하지 않지만 콘솔에서 '맵은 기능이 아닙니다'오류가 발생했습니다. Angular 2에서 Angular 5로 변경된 사항과 지금 사용해야하는 변경 사항을 이해하려고합니다.
import { AngularFireAuth } from 'angularfire2/auth';
import { CanActivate, Router } from '@angular/router';
import { Injectable } from '@angular/core';
import { GlobalController } from '../services/globalController.service';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map';
@Injectable()
export class AuthGuard implements CanActivate {
constructor(private authService: AngularFireAuth, private router: Router, private global: GlobalController) { }
canActivate(): Observable<boolean> {
return this.authService.authState.map(user => {
if (user && !user.isAnonymous) {
this.global.setUserEmail(user.email);
this.global.setUserID(user.uid);
this.global.setUserName(user.displayName);
this.global.setUserPhoneNumber(user.phoneNumber);
if (user.photoURL == null) {
console.log('No Photo Found.');
this.global.setUserPhotoLink(this.global.getDefaultPhotoLink());
}else {
this.global.setUserPhotoLink(user.photoURL);
}
console.log('User Photo Url:' + user.photoURL);
return true; }
this.global.ChangeState(this.global.GlobalStates.preLogin);
return false;
});
}
}
콘솔 로그인 오류
ERROR Error: Uncaught (in promise): TypeError:
this.authService.authState.map is not a function
TypeError: this.authService.authState.map is not a function
at AuthGuard.canActivate (auth-guard.service.ts:14)
at MapSubscriber.__WEBPACK_IMPORTED_MODULE_6_rxjs_operator_map__.a.call [as project] (router.js:3353)
at MapSubscriber._next (map.js:69)
at MapSubscriber.next (Subscriber.js:82)
at ArrayObservable._subscribe (ArrayObservable.js:103)
at ArrayObservable._trySubscribe (Observable.js:171)
at ArrayObservable.subscribe (Observable.js:159)
at MapOperator.call (map.js:49)
at Observable.subscribe (Observable.js:156)
at MergeMapOperator.call (mergeMap.js:78)
at AuthGuard.canActivate (auth-guard.service.ts:14)
at MapSubscriber.__WEBPACK_IMPORTED_MODULE_6_rxjs_operator_map__