如果我在主模块中导入模块进行引导但是如果它在路由器中定义并使用loadChildren
加载,则相同的代码可以正常工作 //router mapping
{
path: 'overview',
loadChildren: 'ein-overview#OverviewModule'
}
//defining observable and updating its value
private _customerDetail = new BehaviorSubject<number>(0);
customerDetail$ = this._customerDetail.asObservable();
processCustomerDetail(n : any) {
this._customerDetail.next(n);
}
我的组件使用loadChildren加载,当可观察的更新时,没有获取更新。
this.subscription = this._customerOverviewService.customerDetail$.subscribe(
(customer : number) => this.customer = customer
);
//template
<p>{{customer.messages}}</p>
<p>{{customer.contactPhone}}</p>
<p>{{customer.primaryPhone}}</p>