0

I have a form with 2 fields, 1 of it is an array. I would like to make this whole form as a array, when i click Add question, it will dynamically have another 2 fields like this.

Add Question 1 - All fields are mandatory (Add question) Ask your question *
Answer 1 *

Add Question 2 - All fields are mandatory Ask your question *
Answer 1 *

Another Answer

I've tried but failed. Please kindly help. Thank you. below is the code in StackBlitz.

StackBlitz: https://stackblitz.com/edit/angular-j92gcm?file=app%2Fapp.component.css

Devora
  • 357
  • 4
  • 14
  • `I've tried but failed` Please elaborate what is the error are you getting? – yurzui Jan 22 '18 at 07:31
  • 1
    http://plnkr.co/edit/clTbNP7MHBbBbrUp20vr?p=preview this should be helpful :) – Abhishek Ekaanth Jan 22 '18 at 07:36
  • See also https://stackoverflow.com/questions/42783400/nested-arrays-in-angular-2-reactive-forms – yurzui Jan 22 '18 at 07:39
  • @AbhishekEkaanth thanks i will try it. Any idea how does the app.component uses the contract.component? I don't see any routing or import. – Devora Jan 22 '18 at 09:16
  • I did not understand. what you are trying to convey. – Abhishek Ekaanth Jan 22 '18 at 09:20
  • As in to use a component in another component, usually there is a or importing in the. ts file. However i dont see any of it. So how does app.component use contract.component. Referring to the link you gave. – Devora Jan 22 '18 at 09:26
  • @yurzui how can i add validation since its in a different omponent for your plunker example. https://plnkr.co/edit/vSODkb8i7o54X3fST9VF?p=preview – Devora Jan 24 '18 at 10:19

0 Answers0