As indicated in other responses, the initial routines of an Angular2 application should be launched in the ngOnInit() method, leaving the constructor specifically for dependency injection.
However, in the Reactive Forms tutorial that I'm following, the initialization of the form is in the constructor:
export class HeroDetailComponent3 {
heroForm: FormGroup; // <--- heroForm is of type FormGroup
constructor(private fb: FormBuilder) { // <--- inject FormBuilder
this.createForm();
}
createForm() {
this.heroForm = this.fb.group({
name: '', // <--- the FormControl called "name"
});
}
}
Is there really a significant difference or is it just a minor issue?