angular-crash-2021
angular-crash-2021 copied to clipboard
error NG8002: Can't bind to 'task' since it isn't a known property of 'app-task-item'.
<app-task-item *ngFor="let task of tasks" [task]="task" >
while sending props from app-tasks to app-task-item it'll showing error while using [task]="task"
I would check in your task-item.component.ts file. Brad's code is good to go.
This is wrong and was giving me the same error.
@Input()
@Output() onDeleteTask: EventEmitter<Task> = new EventEmitter()
task!: Task;
faTimes = faTimes;
This is right and cleared it up. I believe it's letting it know we have a "task" property as the error was referring to.
@Input()
task!: Task;
@Output() onDeleteTask: EventEmitter<Task> = new EventEmitter()
faTimes = faTimes;
Also just looked at the final code and you can see Brad's code at the end has this in the task-item.component.ts. Stating the task is a known input property
@Input() task: Task;
Hope that helps.
I had this problem myself.
Fixed with:
@Input() task!: Task;
Notice the exclamation mark.
In the file: task-item.component.ts