就像在 Headers 中我需要取消订阅我的组件中的行为主题 . 行为主题位于全局静态服务中 . 继承人的行为主体

private _salesPlanId = new BehaviorSubject<number>(undefined);
salesPlanId$ = this._salesPlanId.asObservable();
changeSalesPlanId(data) {
    this._salesPlanId.next(data);
}

我开始在lifececyle OnInit中的组件内订阅它:

ngOnInit() {

   this.mySubscription = this.service.salesPlanId$.subscribe(id => {
        if (id === undefinied){
           this.service.getId.subscribe(id => {
                 this.service.changeSalesPlanId.next(id);
           }
         }else{
               this.id = id;
              }
        }
    });

问题是,我想破坏组件取消订阅元素并将此行为主题再次变为未定义,我这样做:

ngOnDestroy() {
    this.mySubscription.unsubscribe();
    this.flex.changeSalesPlanId(undefined);
}

但是在usubscribe之后的OnDestroy上,我更改了一个salesPlan Inside服务,我看到这个组件重新找到了未定义的值并再次启动了id?有没有走路?