-3

I am creating basic angular reactiveForm but i am getting an errow Property 'employeeForm' has no initializer and is not definitely assigned in the constructor

I followed to set false to the strict in tsconfig.json. When i do this the error dissapears but sand the code gets compiled successfuly but the employeeForm property was underlined with the same error and the programs runs successfully but i when i console the formgroup elemmnts they are not displyed in the console.

That means it is now working. i feel this is because of this error.

Please help me how to intialize the formGruop elements at the time time of declaration or else your own ideas.

[create-employee.component.html1

create-employee.component.ts

  • Does this answer your question? [Property '...' has no initializer and is not definitely assigned in the constructor](https://stackoverflow.com/questions/49699067/property-has-no-initializer-and-is-not-definitely-assigned-in-the-construc) – Yong Shun Jul 02 '21 at 07:10

2 Answers2

0

You need to use

employeeForm!: FormGroup();
Sheno Navy
  • 299
  • 1
  • 7
0

You should move the initialization of employeeForm inside the constructor:

employeeForm: FormGroup;

constructor() {
  this.employeeForm = new FormGroup({...});
}