29 lines
894 B
TypeScript
29 lines
894 B
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { FormBuilder, FormGroup, FormArray, Validators } from '@angular/forms';
|
|
import { Router } from '@angular/router';
|
|
import { EventService } from 'src/app/service/event.service';
|
|
|
|
@Component({
|
|
selector: 'app-event',
|
|
templateUrl: './event.component.html',
|
|
styleUrls: ['./event.component.css']
|
|
})
|
|
export class EventComponent implements OnInit {
|
|
events: any[] = []; // Define the type according to your model
|
|
|
|
constructor(private eventService: EventService, private router: Router) { }
|
|
|
|
ngOnInit(): void {
|
|
this.loadEvents();
|
|
}
|
|
|
|
loadEvents(): void {
|
|
this.eventService.getEvents().subscribe(events => this.events = events);
|
|
}
|
|
|
|
deleteEvent(id: number): void {
|
|
if (confirm('Are you sure you want to delete this event?')) {
|
|
// this.eventService.deleteEvent(id).subscribe(() => this.loadEvents());
|
|
}
|
|
}
|
|
} |