Angular 我试图在同一个商店中选择三个州,但我面临着一些问题

Angular 我试图在同一个商店中选择三个州,但我面临着一些问题,angular,typescript,redux,ngrx,Angular,Typescript,Redux,Ngrx,我的商店有问题,因为在一个商店里,我做了3种状态,我在Angular使用ngrx商店。 问题是,它的一切工作,但我有错误,我的TS 我已经编辑了@Fartab代码答案中的问题,它正在工作,但仍然显示一些错误 这是我到目前为止所做的代码 cluster = Map<string, ClusterItem>(); this.store.select('technicalMatrix').subscribe(state => { this.cluster =

我的商店有问题,因为在一个商店里,我做了3种状态,我在Angular使用ngrx商店。 问题是,它的一切工作,但我有错误,我的TS 我已经编辑了@Fartab代码答案中的问题,它正在工作,但仍然显示一些错误

这是我到目前为止所做的代码

  cluster = Map<string, ClusterItem>();

    this.store.select('technicalMatrix').subscribe(state => {
      this.cluster = state.technicalCluster;
      this.manufactures = state.manufacturer;
       this.store.select('technicalMatrix').subscribe(state => {
  this.cluster = ([...state.technicalCluster,
                          ...state.costCenter,
                          ...state.manufacturer]);
});
}

//  this is for the state [ts] Type 'Map<string, ClusterItem>' is not an array type
// for this.cluster it is showing this error
// Only a void function can be called with the 'new' keyword

我想你需要这样的东西:

allClusters: Map<string, ClusterItem>;

this.store.select('technicalMatrix').subscribe(state => {
    this.allClusters = new Map([...state.technicalCluster, 
                                ...state.manufacturer, 
                                ...state.costCenter]);
});


setVisible() {
     this.selectedMatrix.forEach(clusterId => {
         const matrix = this.allClusters.get(clusterId);
     }
}
allClusters:Map;
this.store.select('technicalMatrix').subscribe(状态=>{
this.allClusters=新映射([…state.technicalCluster,
…州制造商,
…州成本中心];
});
setVisible(){
this.selectedMatrix.forEach(clusterId=>{
常量矩阵=this.allClusters.get(clusterId);
}
}

我想不出你的问题是什么。问题不清楚。@Fartab如何在一个存储中选择3个状态并声明相同的变量?请提及你的存储状态模型我的意思是ApplicationState@Fartab我已经编写了我的应用程序状态代码,但它告诉我一些错误[ts]类型“Map”不是数组类型
setVisible() {
 this.selectedMatrix.forEach(clusterId => {
      const matrix = this.cluster.get(clusterId); //here is just one store selected this.cluster referes to the store state.technicalCluster
}
}
allClusters: Map<string, ClusterItem>;

this.store.select('technicalMatrix').subscribe(state => {
    this.allClusters = new Map([...state.technicalCluster, 
                                ...state.manufacturer, 
                                ...state.costCenter]);
});


setVisible() {
     this.selectedMatrix.forEach(clusterId => {
         const matrix = this.allClusters.get(clusterId);
     }
}