【发布时间】:2019-02-21 17:50:06
【问题描述】:
这是我的 ts 代码:在 this.store.pipe 之后,我将数据分配给 courseList - 但出现打字错误:
错误 src/app/setup-config/setup-config/setup-config.component.ts(55,4): 错误 TS2740:类型“ModelCourse[]”缺少以下属性 来自“可观察”类型:_isScalar、源、运算符、 提升,还有 5 个。
这是什么意思?我需要在这里做什么更正?
import { Component, OnInit } from '@angular/core';
import { Store, select } from '@ngrx/store';
import { StateSetupConfig, ModelCourse } from "./../models";
import { LoadCourse } from "./../state/course.actions";
import * as setupConfigActions from "./../state/setup-config.actions";
import * as actions from "./../state";
import { Observable } from 'rxjs';
declare var $:JQueryStatic;
@Component({
selector: 'setup-config',
templateUrl: './setup-config.component.html',
styleUrls: ['./setup-config.component.scss']
})
export class SetupConfigComponent implements OnInit {
courseList:Observable<ModelCourse[]>
constructor(private store:Store<StateSetupConfig>) { }
ngOnInit(){
this.store.dispatch(new LoadCourse());
this.store.pipe(select(actions.getCourses)).subscribe((data:ModelCourse[]) => {
this.courseList = data;
})
}
}
【问题讨论】:
标签: angular typescript angular7