带有@NGRX/Data 的自定义端点

问题描述

我需要使用@NGRX/Data 修改我的端点。我写了一个在文档中描述的数据服务,它确实改变了端点,问题是数据没有加载到存储中。如何使用此自定义数据服务并在收到数据后将数据加载到存储中?

@Injectable()
export class OfficeCustomService extends DefaultDataService<Office> {
    userId: number;
    territoryId: number;

    constructor(http: HttpClient ) {
        const url = new DefaultHttpUrlGenerator(new DefaultPluralizer([appPluralNames]));
        url.registerHttpResourceUrls({Label: {entityResourceUrl: 'office',collectionResourceUrl: 'offices'}});
        super('Office',http,url,defaultDataServiceConfig);
    }

    protected execute(method: HttpMethods,url: string,data?: any,options?: any): Observable<any> {
        const regex = /offices/gi;
        if (method === 'GET' && url.search(regex) > 0) {
            url = url + 'userId/' + this.userId + '/territoryId/' + this.territoryId;
        }
        return super.execute(method,data,options);
    }

    getAllByUserAndTerritory(userId: number,territoryId: number): Observable<Office[]> {
        this.userId = userId;
        this.territoryId = territoryId;
        return super.getAll();
    }

}

为什么 super.getAll() 函数不将数据加载到存储中?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)