Something went wrong. Try again.
Some angular code i wrote while following: Angular - The Complete Guide (2025 Edition)
Something went wrong. Try again.
TypeScript
at master
123456789101112131415161718192021222324252627282930313233343536373839import { Component, EventEmitter, Input, Output, inject } from '@angular/core';import { FormsModule } from '@angular/forms';
import { TasksService } from '../tasks.service';
@Component({ selector: 'app-new-task', standalone: true, imports: [FormsModule], templateUrl: './new-task.component.html', styleUrl: './new-task.component.css',})export class NewTaskComponent { @Input({ required: true }) userId!: string; @Output() cancel = new EventEmitter<void>();
private taskService = inject(TasksService);
enteredTitle = ''; enteredSummary = ''; enteredDate = '';
onSubmit() { this.taskService.addTask( { title: this.enteredTitle, summary: this.enteredSummary, date: this.enteredDate, }, this.userId, ); this.cancel.emit(); }
onCancel() { this.cancel.emit(); }}