So I'm currently learning Angular V14 with Typescript. I have a component which takes an @Input of Task (Task being an interface):
Component:
import { Component, OnInit, Input } from '@angular/core';
import { Task } from 'src/app/models/Task';
@Component({
selector: 'app-task-item',
templateUrl: './task-item.component.html',
styleUrls: ['./task-item.component.css']
})
export class TaskItemComponent implements OnInit {
@Input() task: Task
constructor() { }
ngOnInit(): void {
}
}
My interface
export interface Task {
id?: number;
text: string;
day: string;
reminder: boolean;
}
However, I get the following error on the following line:
@Input() task: Task
Property 'task' has no initializer and is not definitely assigned in the constructor.
How do I actually initialize an interface within the constructor?