0
export class RegisterComponent implements OnInit {
 
  form: FormGroup;

  constructor(
    private formBuilder: FormBuilder
  ) {}

  ngOnInit(): void {
    this.form = this.formBuilder.group({
      name: '',
      email: '',
      password: ''
    });
  }

}

Error error TS2564: Property 'form' has no initializer and is not definitely assigned in the constructor.

Brandon Taylor
  • 33,823
  • 15
  • 104
  • 144
dorra amri
  • 43
  • 4

1 Answers1

2

Just tell the compiler to rest assured that the member will be initialized.

form!: FormGroup;

It is best to not turn off strictPropertyInitialization, as suggested in the top answer of the referred link.

H3AR7B3A7
  • 4,366
  • 2
  • 14
  • 37