NGXS - 错误:属性没有初始化器并且在构造函数中没有明确分配

时间:2021-08-01 17:53:13

标签: angular typescript ngxs

import { Store } from '@ngxs/store';

@Component({ ... })
export class ZooComponent {
animals$: Observable<string[]>;

constructor(private store: Store) {
this.animals$ = this.store.select(state => state.zoo.animals);
}
}

我正在使用 ngxs/store 但是,我收到以下错误:

error TS2564: Property 'animals$' has no initializer and is not definitely assigned in the constructor.

0 个答案:

没有答案