#Reactive forms - values in the input are not displayed

8 messages · Page 1 of 1 (latest)

exotic crest
#

You are retrieving a list of items, it can't work.

#

The first thing to help you would be to use Types to get hints about the problem.

Doing this should provide you with underline warning parts in your IDE:

this.myService.getDataFromService().subscribe((data) => {
      this.personForm = this.fb.group({
        my_price: [data.my_price, Validators.required],
        email: [data.email, [Validators.required, validateEmail]],
      });
    });
  }
}

As there is no way to find a emailproperty for data as data is an array.

#

You need to provide details about what you aim to do: what is the form about?

silent chasm
#

@exotic crest have one form where I have several inputs. Each of these inputs should display data already from the api. What I want to achieve is to be able to edit these displayed from api items in these inputs. That is, if the value from the api e.g. my_price = 10 then I want to be able to click on that input and edit it and enter e.g. 20.

exotic crest
#

or a table with inputs for each property of each item of your list?

silent chasm
#

In the api I will always have the same 5 objects in an array just with different data.

#

I have created an input table for this