inMemoryDataService无法解析URL

时间:2016-09-29 01:22:08

标签: javascript angular

我已经按照Angular 2教程的建议设置了一个mock inMemoryDataService类。但是,一旦我启动页面,我就会收到错误,无法解析URL。

错误:

/

我甚至尝试在网址前添加export class InMemoryDataService implements InMemoryDbService { createDb() { let commission = { prop: 'string', ... } return { 'commission.json': commission } } } ,但它没有帮助。

mock.ts

export class LogoService {

    constructor(private http: Http) {}

    private connect(): Promise<void> {
        return this.http.get('commission.json').toPromise().then(...)
    }
}

some.service.ts

SELECT *,
       (curdate + interval (case when field(dow, 'Sunday', . . . , 'Sunday') >= dayofweek(curdate)
                                 then field(dow, 'Sunday', . . . , 'Sunday') - dayofweek(curdate)
                                 else 7 + field(dow, 'Sunday', . . . , 'Sunday') - dayofweek(curdate)
                            end) day
        ) as next_class_day
FROM tbl_clubs c LEFT JOIN
     tbh_club_classes cc
     ON c.clubID = cc.clubID LEFT JOIN
     tbl_classes cl
     ON cl.classID = cc.classID;

我知道我并没有真正回复承诺,但它是一个私人功能,而且它还处于其他地方。

1 个答案:

答案 0 :(得分:0)

尝试将文件修改为以下内容:

//mock.ts

export class InMemoryDataService implements InMemoryDbService {
createDb() {
    let commission = {
        prop: 'string',
        ...
    }
    return { commission };
}
}

//some.service.ts
export class LogoService {

constructor(private http: Http) {}

private connect(): Promise<void> {
    return this.http.get('api/commission').toPromise().then(...)
}
}