0

I'm loading data into a form, so if the user wants to change the data they should change the data into input and make a submit, but I have a problem, I can load the data and that's works, but at the momento of get the formControl.Value, I get undefined into the object and I don't understand why, this is my atempt:

Her I init my form and PosibleEditTeam is where I get the values for load.

  this.formEditTeam = this._fb.group({
        TeamName: new FormControl(this.PosibleEditTeam.Name, [Validators.required]),
        ColorMarkerTeam: new FormControl(this.PosibleEditTeam.ColorMark),

and my html form:

  <form *ngIf="isVisibleEditTeam" [formGroup]="formEditTeam">
    <div class="form-row">
      <div class="form-group col-md-6">
        <label for="TeamName"
          ><i class="fa fa-users text-default"></i> Team name</label>
          <input
          type="text"
          class="form-control form-control-sm"
          id="TeamName"
          name="TeamName"
          formControlName="TeamName"
          placeholder="Inserta un nombre"
        />
      </div>
      <div class="form-group col-md-6">
        <label for="ColorMarkerTeam"
          ><i class="fa fa-palette text-default"></i>
        Team</label
        >
        <input
          type="color"
          class="form-control form-control-sm"
          name="ColorMarkerTeam"
          formControlName="ColorMarkerTeam"
          id="ColorMarkerTeam"
        />
      </div>
    </div>
  </form>

is something wrong with it?, if you think that it's ok and the problem is in another place, please ask for information.

1 Answer 1

1

I've reproduced the scenario at Stackblitz.

e.g. I've got of team name using this.formEditTeam.get("TeamName").value; and it works just fine.

Please check the console log for more detail.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.