Hi Guys ,
In this blog I will share information related to error :
TypeError: Cannot convert undefined or null to object.
The complete error log is as follows :
main.ts:13 TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at FormGroup._forEachChild (model.ts:1526)
at FormGroup._setUpControls (model.ts:1531)
at new FormGroup (model.ts:1258)
at new StatusComponent (VM2760 status.component.ts:16)
at createClass (provider.ts:268)
at createDirectiveInstance (provider.ts:136)
at createViewNodes (view.ts:303)
at callViewAction (view.ts:636)
at execComponentViewsAction (view.ts:559)
eval @ main.ts:13
You may get this error while using reactive Forms in Angular
Lets look at the code which caused this error .
You can see the formGroup object is created without passing any parameter to it .
Lets fix this error . We need to add a FormControl to a FormGroup .
The working code is as below .
Hope this helps .Thanks!
In this blog I will share information related to error :
TypeError: Cannot convert undefined or null to object.
The complete error log is as follows :
main.ts:13 TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at FormGroup._forEachChild (model.ts:1526)
at FormGroup._setUpControls (model.ts:1531)
at new FormGroup (model.ts:1258)
at new StatusComponent (VM2760 status.component.ts:16)
at createClass (provider.ts:268)
at createDirectiveInstance (provider.ts:136)
at createViewNodes (view.ts:303)
at callViewAction (view.ts:636)
at execComponentViewsAction (view.ts:559)
eval @ main.ts:13
You may get this error while using reactive Forms in Angular
Lets look at the code which caused this error .
statusForm = new FormGroup();
You can see the formGroup object is created without passing any parameter to it .
Lets fix this error . We need to add a FormControl to a FormGroup .
The working code is as below .
statusForm = new FormGroup(
{
fname : new FormControl('')
}
);
Hope this helps .Thanks!
No comments:
Post a Comment