I have loginForm in my project Stackblitz
But I get an error at 'formControlName':
ERROR TypeError: Cannot read property 'get' of undefined at Object.eval [as updateDirectives] (LoginComponent.html:7) at Object.debugUpdateDirectives [as updateDirectives] (core.js:23910) at checkAndUpdateView (core.js:23306) at callViewAction (core.js:23547) at execComponentViewsAction (core.js:23489) at checkAndUpdateView (core.js:23312) at callViewAction (core.js:23547) at execEmbeddedViewsAction (core.js:23510) at checkAndUpdateView (core.js:23307) at callViewAction (core.js:23547)
My login component:
initForm() {
this.loginForm = this.fb.group({
email: ['', Validators.required ],
password: ['', Validators.required]
});
}
I don't understand where the error appears.
my input-field component Stackblitz
value:string;
onChange: ()=> void;
onTouched: ()=> void;
disabled:boolean;
ngOnInit() {
}
writeValue(value: string): void {
this.value = value ? value: '';
}
registerOnChange(fn: any): void {
this.onChange =fn;
}
registerOnTouched(fn: any): void {
this.onTouched=fn;
}
setDisabledState?(isDisabled: boolean): void {
this.disabled = isDisabled;
}
What Am I missing?