1
votes

I'm using reactive forms in angular 6 with ng2-archwizard

I have checked all the steps but the whole object filled with null values

json Object returned from formGroup

what should I do ?! I have imported reactive form module to parent module and formGroup, FormControl to component ts file..

1
Welcome to stackoverflow! For us to help you, we would need to see the key pieces of code you are using to work with your form. Please edit your question and provide a bit of the HTML that is showing the form and the part of the component code that is building the form. (Please only provide the relevant bits of code.) Thanks!DeborahK
Check out this useful read for new users stackoverflow.com/help/how-to-askNathan Beck
@Ahmed I'm facing the same issue, did you resolve this issue? If yes, please share the solution.LoRe

1 Answers

1
votes

In order to use reactive forms in Angular you need to first import the appropiate module onto your targeted module.ts file. E.g: app.module.ts this way:

@NgModule({
 declarations: [
  AppComponent
  .
  .],
 imports:[
  .
  .
  ReactiveFormsModule],
 entryComponents:[..],
 providers: []
 ....

Then your target component some.component.tsshould look something like this:

myForm = this.fb.group({
 field1:['',[Validators.required,...]],
 field2: ....
)};

constructor(private fb: FormBuilder, ...){}

Then in your html file some.component.html file you just show your form like this:

<form [formGroup]="myForm" (ngSubmit)="yourSubmitFunction(myForm)">
 <div>
  <input formControlName="field1" >
 </div>
 .
 .
 .
 <button type="submit">Submit</button>
</form>

Hope this helps you!.