I have one component under which I have a modal popup containing a child component:
<modal data-backdrop="static" #modalTask (onDismiss)="modalTask.close()" [size]="'lg'"> <modal-header> <h4 style="color:#fff">Add CRL Task</h4> </modal-header> <modal-body> <TaskComponent [isReset] ="resetForm" #tasks></crlTask> </modal-body> <modal-footer> <button type="button" class="btn btn-primary" (click)="onTaskClick();">Create</button> <button type="button" class="btn btn-default" data-dismiss="modal" (click)="modalTask.close();">Cancel</button> </modal-footer> </modal>
Now this child component is as follows:
<form #taskForm="ngForm" name="rplForm"> //Contains Input Controls </form>
EDIT
As one solution was obtained, I set reset inside ngOnChanges child component. Here is the code from the child component
taskForm: FormGroup; @Input() isReset: boolean = false; ngOnChanges() { if (this.isReset) { this.rplForm.reset(); } }
Now I save taskForm to onTaskClick() , and I can do it. What I cannot do is reset the form that is under the child component.
I tried using reset() but could not do it. Anything I can do with the parent component?
source share