1const getCircularReplacer = () => {
2 const seen = new WeakSet();
3 return (key, value) => {
4 if (typeof value === "object" && value !== null) {
5 if (seen.has(value)) {
6 return;
7 }
8 seen.add(value);
9 }
10 return value;
11 };
12};
13
14JSON.stringify(circularReference, getCircularReplacer());
15
1//The error means that the object you pass in the request has a circular reference, something like:
2
3var a = {};
4a.b = a;
1Game.prototype.restart = function () {
2 this.clearLocalStorage();
3 this.timer = setTimeout(this.reset.bind(this), 0); // bind to 'this'
4};
5
6Game.prototype.reset = function(){
7 this.clearBoard(); // ahhh, back in the context of the right 'this'!
8};
9
1ficheiro.html
2<form novalidate #formulario="ngForm">
3
4<pre>{{ formulario.form | json }}</pre>
5
6</form>
7
8Result : ficheiro.html
9
10{
11 "_hasOwnPendingAsyncValidator": false,
12 "_parent": null,
13 "pristine": true,
14 "touched": false,
15 "_onDisabledChange": [],
16 "_rawValidators": null,
17 "_rawAsyncValidators": null,
18 "_composedValidatorFn": null,
19 "_composedAsyncValidatorFn": null,
20 "controls": {},
21 "valueChanges": {
22 "_isScalar": false,
23 "observers": [],
24 "closed": false,
25 "isStopped": false,
26 "hasError": false,
27 "thrownError": null,
28 "__isAsync": false
29 },
30 "statusChanges": {
31 "_isScalar": false,
32 "observers": [],
33 "closed": false,
34 "isStopped": false,
35 "hasError": false,
36 "thrownError": null,
37 "__isAsync": false
38 },
39 "status": "VALID",
40 "value": {},
41 "errors": null
42}