angular-crash-2021 icon indicating copy to clipboard operation
angular-crash-2021 copied to clipboard

error NG8002: Can't bind to 'task' since it isn't a known property of 'app-task-item'.

Open younusesherif opened this issue 3 years ago • 2 comments

<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"

younusesherif avatar Sep 01 '21 19:09 younusesherif

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.

JSinkler713 avatar Sep 19 '21 22:09 JSinkler713

I had this problem myself.

Fixed with:

@Input() task!: Task;

Notice the exclamation mark.

In the file: task-item.component.ts

SamuelHauptmannvanDam avatar Oct 19 '21 19:10 SamuelHauptmannvanDam