类型'TaskModel []'缺少类型'Observable <TaskModel>'中的以下属性:_isScalar,源,运算符,提升

时间:2019-11-14 11:47:31

标签: arrays typescript model observable angular8

可观察到的无法返回数组

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,源,运算符,提升

0 个答案:

没有答案