无法从角度5中的共享服务到组件获取数据更改

时间:2018-11-14 03:05:28

标签: angular5 behaviorsubject

这是我的服务类的外观,可以帮助我创建新的主题并对其进行订阅,每次需要在两个实例中更新数据更改时。

@Injectable()
    export class Managementservice {
    private readonly Client_Management = "management";
    private cachedManagement = new CachedRestCallResponse();

    Constructor(){}

    getManagement(order?: ORDER)Observable<Management> {
      const orderCachedRef = order?: ORDER:'UNKNOWN;
      const var = order ? { order : order } : {};
      if (!this.cachedManagement[orderCachedRef]) {
         this.cachedManagement[orderCachedRef] = this.get<Management> 
    (this.Client_Management, var).publishReplay(1).refCount();
      }
       return this.cachedManagement[orderCachedRef];
    }

    postManagement(management: Management, Order?: ORDER): 
    Observable<Management> {
    const orderCachedRef = order?: ORDER:'UNKNOWN;
    this.cachedManagement[orderCachedRef] = null;
    const var = ( id: ID);
    if (order) {
        var['order'] = order;
    }
        return this.post<Management>(this.Client_Management, management, var);
    }
}

0 个答案:

没有答案