i was following this https://developers.google.com/codelabs/building-a-web-app-with-angular-and-firebase#4 tutorial, and im getting the error on line 11 : todo: Task[] = [...]; in the tutorial it don't say anything about this error, and i am stuck.
import { Component } from '@angular/core';
import { Task } from './task/task';
import { CdkDragDrop, transferArrayItem } from '@angular/cdk/drag-drop';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
})
export class AppComponent {
todo: Task[] = [...];
inProgress: Task[] = [];
done: Task[] = [];
editTask(list: string, task: Task): void {}
drop(event: CdkDragDrop<Task[]>): void {
if (event.previousContainer === event.container) {
return;
}
if (!event.container.data || !event.previousContainer.data) {
return;
}
transferArrayItem(
event.previousContainer.data,
event.container.data,
event.previousIndex,
event.currentIndex
);
}
}
i have tried to check and update the typescript version but nothing change.
CodePudding user response:
todo: Task[] = [...]
is not valid syntax.
It should either be []
or a valid array of Task
objects (which is potentially what the tutorial was hinting at). Just by looking at the code though, I would be tempted to say that todo: Task[] = []
is more appropriate
CodePudding user response:
I guess you should add data of array from previous lesson https://developers.google.com/codelabs/building-a-web-app-with-angular-and-firebase#3
todo: Task[] = [
{
title: 'Buy milk',
description: 'Go to the store and buy milk'
},
{
title: 'Create a Kanban app',
description: 'Using Firebase and Angular create a Kanban app!'
}
];
Or you can use an empty array []