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

@ -14,9 +14,9 @@ import { TaxService } from '../tax.service';
styleUrls: ['./tax-detail.component.css'],
})
export class TaxDetailComponent implements OnInit, AfterViewInit {
@ViewChild('nameElement', { static: true }) nameElement: ElementRef;
@ViewChild('nameElement', { static: true }) nameElement?: ElementRef;
form: FormGroup;
item: Tax;
item: Tax = new Tax();
constructor(
private route: ActivatedRoute,
@ -26,10 +26,7 @@ export class TaxDetailComponent implements OnInit, AfterViewInit {
private toaster: ToasterService,
private ser: TaxService,
) {
this.createForm();
}
createForm() {
// Create form
this.form = this.fb.group({
name: '',
rate: '',
@ -37,7 +34,8 @@ export class TaxDetailComponent implements OnInit, AfterViewInit {
}
ngOnInit() {
this.route.data.subscribe((data: { item: Tax }) => {
this.route.data.subscribe((value) => {
const data = value as { item: Tax };
this.showItem(data.item);
});
}
@ -52,7 +50,9 @@ export class TaxDetailComponent implements OnInit, AfterViewInit {
ngAfterViewInit() {
setTimeout(() => {
this.nameElement.nativeElement.focus();
if (this.nameElement !== undefined) {
this.nameElement.nativeElement.focus();
}
}, 0);
}
@ -69,7 +69,7 @@ export class TaxDetailComponent 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('/taxes');