31 lines
665 B
TypeScript
31 lines
665 B
TypeScript
import {Component, Input, OnInit} from '@angular/core';
|
|
import {Event} from '../../models/event';
|
|
import {ApiService} from '../../services/api.service';
|
|
|
|
@Component({
|
|
selector: '[app-event]',
|
|
templateUrl: './event.component.html',
|
|
styleUrls: ['./event.component.css']
|
|
})
|
|
export class EventComponent implements OnInit {
|
|
|
|
@Input() event: Event | undefined;
|
|
|
|
editActive: boolean = false;
|
|
constructor(private api: ApiService) {
|
|
}
|
|
|
|
ngOnInit(): void {
|
|
}
|
|
|
|
toggleEdit() {
|
|
if(this.editActive && this.event !== undefined) {
|
|
this.api.updateEvent(this.event).subscribe((res: any) => {
|
|
console.log(res);
|
|
});
|
|
}
|
|
|
|
this.editActive = !this.editActive;
|
|
}
|
|
}
|