Angular 未捕获(承诺中):TypeError:无法读取属性';eso';空的

Angular 未捕获(承诺中):TypeError:无法读取属性';eso';空的,angular,Angular,我正在使用App_初始化器调用一个服务。在我的app.module.ts provider部分中,我有两个app_初始值设定项,如下所示: public load() { return new Promise((resolve, reject) => { this.http.get('../config/config.json') .map(res => res).catch((error: any) =>

我正在使用App_初始化器调用一个服务。在我的app.module.ts provider部分中,我有两个app_初始值设定项,如下所示:

 public load() {
        return new Promise((resolve, reject) => {
            this.http.get('../config/config.json')
                .map(res => res).catch((error: any) => {
                    return Observable.throw(error.json().error || 'Server error');
                }).subscribe((configResponse: any) => {
                    debugger;
                    this.config = configResponse;
                    resolve(true);
                });

        });
    }
//app.module.ts

{
    provide: APP_INITIALIZER,
    useFactory: (config: AppConfig) => () => config.load(),
    deps: [AppConfig],
    multi: true
},
{
    provide: APP_INITIALIZER,
    useFactory: (config: AntiforgeryService) => () => config.Load(),
    deps: [AntiforgeryService, GlobalService],
    multi: true
}
//加载方法在AntoForgerService中如下所示

Load(): Promise<any> {
        var date = new Date();
        var sourceDate = date.getDate() + "*" + date.getDay() + "%" + date.getFullYear();

        return new Promise((resolve, reject) => {
            this.http.get(this.forgeryService + '/CMMService-service/GetAntiForgeryToken', { headers: new HttpHeaders().set('X-XSRF-KEY', 'GCMT-' + sourceDate) })
                .map(res => res).catch((error: any) => {
                    return Observable.throw(error.json().error || 'TOKEN error');
                }).subscribe((configResponse: any) => {
                    this.parseTokenData(configResponse);
                    resolve(true);
                });
        });
    }

parseTokenData(data: any) {
        debugger;

        if (data!=null)
        {
            var result = JSON.parse(data.value);
            this.cookieToken = result.CookieToken;
            this.headerToken = result.HeaderToken;

            this.globalService.cookieToken = this.cookieToken;
            this.globalService.headerToken = this.headerToken;
        }
    }
在我的AntiforgeryService中,我还使用了一个名为GlobalService的服务

我也在使用AuthGuard,请查找以下AuthGuard代码:

import { Injectable } from '@angular/core';
import { CanActivate } from '@angular/router';
import { AuthService } from './auth.service';
import { GlobalService } from '../services/GlobalService';

@Injectable()
export class AuthGuard implements CanActivate {

    constructor(private authService: AuthService, private globalService: GlobalService) {
    }

    canActivate(): boolean {
        debugger;
        if (window.location.href.indexOf("localhost") == -1) {
            return true;
        }

        return this.authService.handleAuthentication();
    }
}
在AuthGuard中,我们有函数handleAuthentication,在此函数中,我们使用一个配置文件来获取ESO详细信息,如下所示:

 public load() {
        return new Promise((resolve, reject) => {
            this.http.get('../config/config.json')
                .map(res => res).catch((error: any) => {
                    return Observable.throw(error.json().error || 'Server error');
                }).subscribe((configResponse: any) => {
                    debugger;
                    this.config = configResponse;
                    resolve(true);
                });

        });
    }

有人能告诉我问题出在哪里吗?

我看不到代码中您引用的
eso
。。。你能看到错误在哪一行吗?@user184994请现在检查,我已经添加了相对的错误。我希望它现在能让你明白。我仍然看不到你在哪里使用类似
.eso
的东西。如果在浏览器中检查错误消息,则哪一行抛出错误?