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 { DeviceService } from '../device.service';
styleUrls: ['./device-detail.component.css'],
})
export class DeviceDetailComponent implements OnInit, AfterViewInit {
@ViewChild('nameElement', { static: true }) nameElement: ElementRef;
@ViewChild('nameElement', { static: true }) nameElement?: ElementRef;
form: FormGroup;
sections: Section[];
item: Device;
sections: Section[] = [];
item: Device = new Device();
constructor(
private route: ActivatedRoute,
@ -28,10 +28,7 @@ export class DeviceDetailComponent implements OnInit, AfterViewInit {
private toaster: ToasterService,
private ser: DeviceService,
) {
this.createForm();
}
createForm() {
// Create form
this.form = this.fb.group({
name: '',
section: '',
@ -40,7 +37,8 @@ export class DeviceDetailComponent implements OnInit, AfterViewInit {
}
ngOnInit() {
this.route.data.subscribe((data: { item: Device; sections: Section[] }) => {
this.route.data.subscribe((value) => {
const data = value as { item: Device; sections: Section[] };
this.showItem(data.item);
this.sections = data.sections;
});
@ -57,7 +55,9 @@ export class DeviceDetailComponent implements OnInit, AfterViewInit {
ngAfterViewInit() {
setTimeout(() => {
this.nameElement.nativeElement.focus();
if (this.nameElement !== undefined) {
this.nameElement.nativeElement.focus();
}
}, 0);
}
@ -74,7 +74,7 @@ export class DeviceDetailComponent implements OnInit, AfterViewInit {
}
delete() {
this.ser.delete(this.item.id).subscribe(
this.ser.delete(this.item.id as string).subscribe(
() => {
this.toaster.show('Success', '');
this.router.navigateByUrl('/devices');