import {Component, inject, Input, OnInit} from '@angular/core'
import {ITask} from '../../../models/ITask'
import {TaskService} from '../../services/task.service'

@Component({
  selector: 'app-task-item',
  templateUrl: './task-item.component.html',
  styleUrls: ['./task-item.component.scss'],
})
export class TaskItemComponent implements OnInit {

  // Since we've ensured that this property is required,
  // we can safely use the non-null assertion.
  @Input({required: true}) task!: ITask

  taskService = inject(TaskService)

  constructor() {
    // The instance variable task is NOT available in the constructor.
    // The variable will only be initialized after the constructor has finished.
    // Any other method that is called from the constructor is also unable to use the instance variable.
  }

  ngOnInit() {
    // This is the first method where the class variable task can be used.
  }
}
