Ionic Angular.
I have a reactive form where I want to push the results of formControls into into an String-Array. The push-command gives the error “Type error: this.wo1 is undefined”.
HTML: ` <form [formGroup]=“nxtForm”>
Montag
Dienstag
Mittwoch
TS:` public nxtForm: FormGroup;
wo1: Array;
mo: string;
mot: string;
di: string;
dit: string;
mi: string;
mit: string;
constructor(
public formBuilder: FormBuilder,
private router: Router) {this.nxtForm = this.formBuilder.group({
mo: ‘’,
di: ‘’,
mi: ‘’,
wo1: ,
});
}
ngOnInit() {
}
goNext() {
if (this.mo === ‘f’) {
this.mot = ‘MO: früh’;
} else if (this.mo === ‘s’) {
this.mot = ‘MO: spät’;
} else if (this.mo === ‘t’) {
this.mot = ‘MO: 24h’;
}
this.wo1.push(this.mot); ’
… The last line i the one causing the error.
Thanks for your help!
Edit: in the shown code, wo1 is defined as Array. In fact, I also defined it as a string. I don’t know why thjis is not shown in the published text?