我试图订阅一个引用BehaviorSubject的observable,但是当从服务器检索数据时,它从不加载来自observable的数据 . 我可以看到它从服务中记录,但是在我订阅了observable的组件中,它什么也没做 .

我知道这有多个SO线程,而且我在这个时候没有运气 . 有人可以看看这个,让我知道他们是否看到了明显的东西?

谢谢,

服务:

public dataComplete$ = new BehaviorSubject<any>('');
public dataItem$ = this.dataComplete$.asObservable();
getAsyncRefills(linkToken){
   return this.httpC.get(this.baseUrl + "/AccountInfo/Refills?linkToken=" + linkToken + "&deliveryTypeId=" + 0 + "&pickupLocationId=" + 0 + "&paymentTypeId=" + 0).map((res:Response) => res.json()).subscribe(res => {
       this.asycCollection = res;
        this.dataComplete$.next(Object.assign({},this.asycCollection));
       console.log(this.dataItem$); // This logs an Observable that has a _value property with the data from the http call
    })
}

那么这是我的组件:

ngOnInit(){
    this.buildRefillUsers();
    this.getAddressTypes();
    this.subscription = this.refillService.dataItem$.subscribe(item => {
        if(!item) return;
        console.log(item);
    })
}