In this blog we will discuss on how to load a dynamic HTML into a div .
Lets assume the source of the HTML is a service .
In angular , you can perform this using a user defined directive and ng-template .
In this blog I will share information related to error :
Error: Cannot find control with name:
The complete error log is as follows :
StatusComponent.html:2 ERROR Error: Cannot find control with name: 'sname' at _throwError (shared.ts:140) at setUpControl (shared.ts:36) at FormGroupDirective.addControl (form_group_directive.ts:132) at FormControlName._setUpControl (form_control_name.ts:278) at FormControlName.ngOnChanges (form_control_name.ts:207) at checkAndUpdateDirectiveInline (provider.ts:208) at checkAndUpdateNodeInline (view.ts:429) at checkAndUpdateNode (view.ts:389) at debugCheckAndUpdateNode (services.ts:431) at debugCheckDirectivesFn (services.ts:392)
You may get this error while using reactive Forms in Angular
Lets look at the code which caused this error .
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 =newFormGroup();
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 .
In this blog I will share information related to error :
can't bind to 'formcontrol' since it isn't a known property of 'input'.
The complete error log is as follows :
Error in /turbo_modules/@angular/compiler@8.0.0/bundles/compiler.umd.js (2479:21)
Template parse errors:
Can't bind to 'formControl' since it isn't a known property of 'input'. ("<label>
Name:
<input type="text" [ERROR ->][formControl]="status">
</label>"): ng:///AppModule/StatusComponent.html@2:21
No provider for NgControl ("<label>
Name:
[ERROR ->]<input type="text" [formControl]="status">
</label>"): ng:///AppModule/StatusComponent.html@2:2
You may get this error while using angular reactive forms .
To fix this error add RectiveFormsModule in the inports array .
This blog is about the error " JSX expressions must have one parent element.
Let's look at the erroneous code .
importReactfrom'react';
exportdefault({ name })=><h1>Hello{name}!</h1>
<input type="text" placeholder="enter asset"/>;
You can see there are two elements <h1> and <input> .
The error is because react does not allow multiple component as a parent component . To fix this issue we can put the two elements under single parent component , like a <div> .
Let's fix the code .
importReactfrom'react';
exportdefault({ name })=><div><h1>Hello{name}!</h1>