43 lines
858 B
TypeScript
43 lines
858 B
TypeScript
import { Inject, Component, OnInit } from '@angular/core';
|
|
import { MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog';
|
|
|
|
@Component({
|
|
selector: 'app-tips',
|
|
templateUrl: './tips.component.html',
|
|
styleUrls: ['./tips.component.css']
|
|
})
|
|
|
|
export class TipsComponent implements OnInit{
|
|
orderTotal:number = 0;
|
|
value:number = 0.15;
|
|
flag:boolean = true;
|
|
|
|
constructor(
|
|
private dialogRef: MatDialogRef<TipsComponent>,
|
|
@Inject(MAT_DIALOG_DATA) public data: {amt: number, flag: boolean}) {
|
|
this.orderTotal = data.amt;
|
|
this.flag = data.flag;
|
|
if(!data.flag){
|
|
this.dialogRef.close(0);
|
|
}
|
|
}
|
|
|
|
ngOnInit(): void {
|
|
if(!this.flag){
|
|
this.dialogRef.close(0);
|
|
}
|
|
}
|
|
|
|
formatPercent(v: number) {
|
|
return (v * 100) + '%';
|
|
}
|
|
|
|
close() {
|
|
this.dialogRef.close(0);
|
|
}
|
|
|
|
confirm() {
|
|
this.dialogRef.close(this.orderTotal * this.value);
|
|
}
|
|
}
|