0

I've got a form, and Im adding items to an array - I want to display that array on the form below where the items are added, so the user has feedback...

If I display the full form value, I see the array just fine, however if I try to display ONLY the array, nothing shows up - and no errors.

so

{{ form.value | json }}

gives me this:

{
    myArray: ["some value","another value"]
}

and if I try to do this:

{{ form.myArray }} or {{ form.myArray.value }}

I get nothing...

Any help is appreciated

Excellent answers - thanks - however

{{ form.value.myArray }}

Only gives me the first element, I want the whole array (as a list), what might I be doing wrong now.

1
  • form.value[myArray][0] try this way Commented Jul 6, 2018 at 4:04

3 Answers 3

3

You need to use

{{ form.value.myArray }}  

and if you need the first element,

{{ form.value.myArray[0] }}  
Sign up to request clarification or add additional context in comments.

2 Comments

Excellent answers - thanks - however {{ form.value.myArray }} Only gives me the first element, I want the whole array (as a list), what might I be doing wrong now.
then you need to loop
1

You can change your code to

{{form.value[myArray][0]}} //to access first element in array

Comments

0

You can use :

<div *ngFor = "let elm of form.value.myArray">
{{elm}}
</div>

Or to diaplay all use:

{{form.value.myArray}}

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.