我的公司对象在我的视图中没有显示任何值。当我将subscribe方法附加到实例时,一切都正确显示在控制台中。
查看:
<h2>{{scopedCompany$.name | async}}</h2>
<h2 *ngFor="let company of companies$ | async">{{company.name}}</h2>
组件:
@select('scopedCompany') scopedCompany$: Observable<Company>;
@select('companies') companies$: Observable<Company[]>;
constructor(
private securityService: OidcSecurityService,
private ngRedux: NgRedux<IAppState>,
private navigation: NavigationService
) { }
ngOnInit() {
this.scopedCompany$.subscribe(x => console.log(x));
}
应用模块:
export class AppModule {
constructor(ngRedux: NgRedux<IAppState>) {
ngRedux.provideStore(store);
}
}
export interface IAppState {
companies: Company[];
scopedCompany: Company;
}
公司数组显示name属性,但scopedCompany不显示。