Updated to angular 11
Now compiling with strict mode in typescript Need to error checking now
This commit is contained in:
@ -11,9 +11,9 @@ import { DiscountDataSource } from './discount-datasource';
|
||||
styleUrls: ['./discount.component.css'],
|
||||
})
|
||||
export class DiscountComponent {
|
||||
list: any[];
|
||||
list: any[] = [];
|
||||
form: FormGroup;
|
||||
dataSource: DiscountDataSource;
|
||||
dataSource: DiscountDataSource = new DiscountDataSource([]);
|
||||
|
||||
displayedColumns = ['name', 'discount'];
|
||||
|
||||
@ -22,7 +22,9 @@ export class DiscountComponent {
|
||||
private fb: FormBuilder,
|
||||
@Inject(MAT_DIALOG_DATA) public data: Observable<any[]>,
|
||||
) {
|
||||
this.createForm();
|
||||
this.form = this.fb.group({
|
||||
discounts: '',
|
||||
});
|
||||
this.data.subscribe((list: any[]) => {
|
||||
this.list = list;
|
||||
this.form.setControl(
|
||||
@ -40,12 +42,6 @@ export class DiscountComponent {
|
||||
});
|
||||
}
|
||||
|
||||
createForm() {
|
||||
this.form = this.fb.group({
|
||||
discounts: '',
|
||||
});
|
||||
}
|
||||
|
||||
accept(): void {
|
||||
const array = this.form.get('discounts') as FormArray;
|
||||
this.list.forEach((item, index) => {
|
||||
|
||||
Reference in New Issue
Block a user