Updated to angular 11

Now compiling with strict mode in typescript
Need to error checking now
This commit is contained in:
2020-11-22 10:13:37 +05:30
parent cabd6f2ea1
commit 6567f560ab
187 changed files with 1709 additions and 1184 deletions

View File

@ -15,10 +15,10 @@ import { HeaderFooterService } from './header-footer.service';
styleUrls: ['./header-footer.component.css'],
})
export class HeaderFooterComponent implements OnInit {
@ViewChild('section', { static: true }) sectionElement: ElementRef;
@ViewChild('section', { static: true }) sectionElement?: ElementRef;
form: FormGroup;
list: HeaderFooter[];
id: string;
list: HeaderFooter[] = [];
id = '';
constructor(
private route: ActivatedRoute,
@ -28,30 +28,29 @@ export class HeaderFooterComponent implements OnInit {
private dialog: MatDialog,
private ser: HeaderFooterService,
) {
this.createForm();
// Create form
this.form = this.fb.group({
id: '',
text: '',
});
route.params.pipe(map((p) => p.id)).subscribe((x) => {
this.id = x;
});
}
createForm() {
this.form = this.fb.group({
id: '',
text: '',
});
}
ngOnInit() {
this.route.data.subscribe((data: { list: HeaderFooter[] }) => {
this.route.data.subscribe((value) => {
const data = value as { list: HeaderFooter[] };
this.showItem(data.list);
});
}
showItem(list: HeaderFooter[]) {
this.list = list;
const val = this.list.find((v) => v.id === this.id) as HeaderFooter;
this.form.setValue({
id: this.id,
text: this.list.find((v) => v.id === this.id).text,
text: val.text,
});
}
@ -70,6 +69,7 @@ export class HeaderFooterComponent implements OnInit {
getItem(): HeaderFooter {
const formModel = this.form.value;
const item = this.list.find((v) => v.id === this.id);
if (item === undefined) return new HeaderFooter();
item.text = formModel.text;
return item;
}