TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
San
NA
804
323.8k
ngModel cannot be used to register form controls with a pare
Dec 13 2019 6:34 AM
After Add below code for dropdown validation
<form #GroupForm1="ngForm" [formGroup]="filtersForm" (ngSubmit)="onSubmit(GroupForm1)" >
<th>
<select formControlName="Dropdown" style="width:100%;height:30px" (change)="selectedGroupID($event.target.value)" >
<option [value]="null">--Select--</option>
<option [value]="prot.GroupID" *ngFor="let prot of ProductGroupdataAll" >
{{prot.Group}}
</option>
</select>
<span *ngIf="hasDropDownError">Enter Country ...</span>
</th>
getting below error.
ERROR Error: "
ngModel cannot be used to register form controls with a parent formGroup directive. Try using
formGroup's partner directive "formControlName" instead. Example:
<div [formGroup]="myGroup">
<input formControlName="firstName">
</div>
In your class:
this.myGroup = new FormGroup({
firstName: new FormControl()
});
Or, if you'd like to avoid registering this form control, indicate that it's standalone in ngModelOptions:
Example:
<div [formGroup]="myGroup">
<input formControlName="firstName">
<input [(ngModel)]="showMoreControls" [ngModelOptions]="{standalone: true}">
</div>
"
Angular 9
View_groupComponent_2 groupComponent.html:82
Angular 32
RxJS 5
Angular 11
groupComponent.html:74:37
ERROR CONTEXT
Object { view: {…}, nodeIndex: 49, nodeDef: {…}, elDef: {…}, elView: {…} }
groupComponent.html:74:37
ERROR Error: "
ngModel cannot be used to register form controls with a parent formGroup directive. Try using
formGroup's partner directive "formControlName" instead. Example:
<div [formGroup]="myGroup">
<input formControlName="firstName">
</div>
In your class:
this.myGroup = new FormGroup({
firstName: new FormControl()
});
Or, if you'd like to avoid registering this form control, indicate that it's standalone in ngModelOptions:
Example:
<div [formGroup]="myGroup">
<input formControlName="firstName">
<input [(ngModel)]="showMoreControls" [ngModelOptions]="{standalone: true}">
</div>
"
Reply
Answers (
1
)
Sample Angular Application
Nested Angular Module Routing Not Working in angular 8