项目作者: yiqu

项目描述 :
Form in Recursion
高级语言: TypeScript
项目地址: git://github.com/yiqu/recursion-ng-forms.git
创建时间: 2021-02-27T21:29:40Z
项目社区:https://github.com/yiqu/recursion-ng-forms

开源协议:

下载


RecursionForms

Build Status

Demo: https://yiqu.github.io/recursion-ng-forms/

Form Structure:

  • Address (form control)

  • Year (form control)

  • Habitant (form group)

    • habitantName (form control)
    • age (form control)
    • dependents (form array)
      • The dependents array contains form groups that has a ‘dependent_type’ form control. The ‘dependent_type’ is a selection of 3 possible values: deceased, pet, or habitant. If habitant is chosen, display the Habitant form group again explained here.

The dependents form array could contain a Habitant, which in turn contains dependents which could contain Habitants. Thus a recursion is needed for creating and displaying the form.

Example result:

  1. {
  2. "address":"1000 Friendly St.",
  3. "year":"2021",
  4. "habitant":{
  5. "habitantName":"Fist hab name",
  6. "age":"First hab age",
  7. "dependents":[
  8. {
  9. "dependent_type":"animal",
  10. "petName":"First hab's animal name"
  11. },
  12. {
  13. "dependent_type":"habitant",
  14. "habitant":{
  15. "habitantName":"Second hab name",
  16. "age":"Second hab age",
  17. "dependents":[
  18. {
  19. "dependent_type":"habitant",
  20. "habitant":{
  21. "habitantName":"Third hab name",
  22. "age":"Third hab age",
  23. "dependents":[
  24. {
  25. "dependent_type":"deceased"
  26. },
  27. {
  28. "dependent_type":"habitant",
  29. "habitant":{
  30. "habitantName":"Fourth hab name",
  31. "age":"Fourth hab age",
  32. "dependents":[
  33. {
  34. "dependent_type":null
  35. }
  36. ]
  37. }
  38. }
  39. ]
  40. }
  41. }
  42. ]
  43. }
  44. }
  45. ]
  46. }
  47. }