angular-hotel-manager/src/app/Child/child.component.ts

26 lines
571 B
TypeScript
Raw Normal View History

2024-08-20 14:26:19 +02:00
import { Component, Input, Output, EventEmitter } from "@angular/core";
@Component({
selector: 'app-child',
standalone: true,
templateUrl: './child.component.html',
})
export class ChildComponent {
@Input() public balance: number = 0;
2024-08-20 14:26:19 +02:00
@Output() balanceChange = new EventEmitter<number>();
public isBroke = false;
2024-08-20 14:26:19 +02:00
public takeMoney() {
if (this.balance <= 0) {
this.isBroke = true;
} else {
this.balance -= 50;
if (this.balance == 0) {
this.isBroke = true;
}
this.balanceChange.emit(this.balance);
}
2024-08-20 14:26:19 +02:00
}
}