Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

285
Views
how to perform JSON.stringify on objects with ciruclar reference?

I would like to store a formgroup object in database. I am not able to stringify this object because of circular dependency. Is there a workaround for this in angular?

form ={ coursename: new FormControl('', Validators.required), content: new FormControl('',Validators.required), }

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

// your code
const form = {
  coursename: new FormControl("", Validators.required),
  content: new FormControl("", Validators.required),
};

// since new FormControl() create an object with circular reference,
// so instead of taking the FormControl object, we can use FormControl.value
// which return the actual data object with no circular reference

// updated code
courseNameControl = new FormControl("", Validators.required);
contentControl = new FormControl("", Validators.required);
const form = {
  coursename: courseNameControl.value,
  content: contentControl.value,
}

// now you can stringify the form
const stringifyForm = JSON.stringify(form);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!