Updated to angular 11
Now compiling with strict mode in typescript Need to error checking now
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||
|
||||
import { DiscountComponent } from './discount.component';
|
||||
|
||||
@ -6,11 +6,13 @@ describe('DiscountComponent', () => {
|
||||
let component: DiscountComponent;
|
||||
let fixture: ComponentFixture<DiscountComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [DiscountComponent],
|
||||
}).compileComponents();
|
||||
}));
|
||||
beforeEach(
|
||||
waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [DiscountComponent],
|
||||
}).compileComponents();
|
||||
}),
|
||||
);
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(DiscountComponent);
|
||||
|
||||
@ -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