Angular 具有Observable的Dictionary对象:无法读取属性';下一个';未定义的 isEnabledDeleteCourtChanged$:{[courtId:string]:可观察}; 私有isEnabledDeleteCourtSubject$:{[courtId:string]:BehaviorSubject}; 私有初始化():void{ this.isEnabledDeleteCourtSubject$=new BehaviorSubject(false);//这里有问题 this.isEnabledDeleteCourtChanged$=this.isEnabledDeleteCourtSubject$.asObservable();//此处有问题 } setIsEnabledDeleteCourt(courtId:string,isEnabled:boolean):无效{ this.isEnabledDeleteCourtSubject$[courtId].next(isEnabled);//此处有问题 }

Angular 具有Observable的Dictionary对象:无法读取属性';下一个';未定义的 isEnabledDeleteCourtChanged$:{[courtId:string]:可观察}; 私有isEnabledDeleteCourtSubject$:{[courtId:string]:BehaviorSubject}; 私有初始化():void{ this.isEnabledDeleteCourtSubject$=new BehaviorSubject(false);//这里有问题 this.isEnabledDeleteCourtChanged$=this.isEnabledDeleteCourtSubject$.asObservable();//此处有问题 } setIsEnabledDeleteCourt(courtId:string,isEnabled:boolean):无效{ this.isEnabledDeleteCourtSubject$[courtId].next(isEnabled);//此处有问题 },angular,typescript,ionic-framework,rxjs,Angular,Typescript,Ionic Framework,Rxjs,上述代码不起作用。它表示无法读取未定义的属性“next”。那么你能告诉我如何正确地构造可观测的Dictionary对象吗?初始化也不起作用?i、 e.initialize()查看它所属的对象isEnabledDeleteCourtSubject$您真的想在它的末尾添加$吗?是否需要$?设置时,您有isEnabledDeleteCourtSubject$=没有空格-可能是未定义的问题?在这里,如果没有courtId我们无法声明/初始化它。这对我来说很有用 服务台 isEnabledRevertTo

上述代码不起作用。它表示
无法读取未定义的属性“next”
。那么你能告诉我如何正确地构造可观测的Dictionary对象吗?初始化也不起作用?i、 e.
initialize()

查看它所属的对象
isEnabledDeleteCourtSubject$
您真的想在它的末尾添加$吗?是否需要$?设置时,您有
isEnabledDeleteCourtSubject$=
没有空格-可能是未定义的问题?

在这里,如果没有
courtId
我们无法声明/初始化它。这对我来说很有用

服务台

isEnabledRevertToGroupChanged$:{[courtId:string]:可观察}={};
私有isEnabledRevertToGroupSubject$:{[courtId:string]:BehaviorSubject}={};
setIsEnabledDeleteCourt(courtId:string,isEnabled:boolean):无效{
this.isEnabledDeleteCourtSubject$[courtId]=新行为主体(false);
this.isEnabledDeleteCourtSubject$[courtId].next(isEnabled);
this.isEnabledDeleteCourtChanged$[courtId]=this.isEnabledDeleteCourtSubject$[courtId].asObservable();
}
html


 isEnabledDeleteCourtChanged$: { [courtId: string]: Observable<boolean> };

 private isEnabledDeleteCourtSubject$: { [courtId: string]: BehaviorSubject<boolean> };

 private initialize(): void {

  this.isEnabledDeleteCourtSubject$= new BehaviorSubject<boolean>(false); // here has problem
  this.isEnabledDeleteCourtChanged$ = this.isEnabledDeleteCourtSubject$.asObservable(); // here has problem
}

 setIsEnabledDeleteCourt(courtId: string, isEnabled: boolean): void {

    this.isEnabledDeleteCourtSubject$[courtId].next(isEnabled); // here has problem
}
isEnabledRevertToGroupChanged$: { [courtId: string]: Observable<boolean> } = {};

private isEnabledRevertToGroupSubject$: { [courtId: string]: BehaviorSubject<boolean> } = {};

setIsEnabledDeleteCourt(courtId: string, isEnabled: boolean): void {

        this.isEnabledDeleteCourtSubject$[courtId] = new BehaviorSubject<boolean>(false);

        this.isEnabledDeleteCourtSubject$[courtId].next(isEnabled);

        this.isEnabledDeleteCourtChanged$[courtId] = this.isEnabledDeleteCourtSubject$[courtId].asObservable();
    }
 <ion-col *ngIf="queueDataService?.isEnabledDeleteCourtChanged$[queue?.qId] | async">
 </ion-col>