可观察到的无法返回数组
private readonly task = new BehaviorSubject<TaskModel[]>([]); public readonly tasks$ =
this.task.asObservable(); private model: TaskModel = new
TaskModel(); get TASKS(): TaskModel[] {
return this.task.getValue(); }
set TASKS(tasks: TaskModel[]) {
this.task.next(tasks); }
constructor() {
this.getAllConfigs().subscribe(); }
getAllConfigs(): Observable<TaskModel[]> {
let task: TaskModel[] = [];
task = [...this.TASKS];
return this.task; }
create(model: TaskModel): Observable<TaskModel> {
const tasks: TaskModel[] = [];
// let tasksd: TaskModel[] = [];
const task: TaskModel = new TaskModel();
tasks.forEach(ts => {
ts.id = task.id;
ts.name = task.name;
});
this.TASKS = [...tasks];
return this.TASKS; }
//model export class TaskModel { id: number; name: string; categoryId: number; }
错误是:
类型“ TaskModel []”缺少类型“可观察”的以下属性:_isScalar,源,运算符,提升