Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. @Input() data: CivilLiabilityQuestionnaireModel;
  2. public questions: CivilLiabilityQuestionnaireModel;
  3.  
  4. this.questions = { ...this.data };
  5.  
  6. const questionGroupIndex = 0;
  7. const questionGroupItemIndex = 0;
  8.  
  9. this.questions
  10. .questionGroup[questionGroupIndex]
  11. .questionGroupItems[questionGroupItemIndex]
  12. .answers[0]
  13. .value = form[val];
  14.  
  15. // This works
  16. this.questions.id = 'hotdog';
  17.  
  18. // This doesn't work
  19. // ERROR TypeError: Cannot assign to read only property 'id' of object '[object Object]'
  20. this.questions.questionGroup[questionGroupIndex].id = 'hamburger';
  21.  
  22. this.questions = {
  23. ...this.questions,
  24. questionGroup: {
  25. ...this.questions.questionGroup,
  26. [questionGroupIndex]: {
  27. ...this.questions.questionGroup[questionGroupIndex],
  28. questionGroupItems: {
  29. ...this.questions.questionGroup[questionGroupIndex].questionGroupItems,
  30. [questionGroupItemIndex]: {
  31. ...this.questions.questionGroup[questionGroupIndex].questionGroupItems[questionGroupItemIndex],
  32. answers: {
  33. ...this.questions.questionGroup[questionGroupIndex].questionGroupItems[questionGroupItemIndex].answers,
  34. [0]: {
  35. ...this.questions.questionGroup[questionGroupIndex].questionGroupItems[questionGroupItemIndex].answers[0],
  36. value: form[val]
  37. }
  38. }
  39. }
  40. }
  41. }
  42. }
  43. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement