Angular - undo manager not works

Hi Walter and friends, I have two problems that I would like to get your help with.

  1. I moved my project to work with gojs-angular instead gojs library, and I have a problem with the undo manager that wasn’t there before.
    In the initDiagram function, I configured the diagram with ‘undoManager.isEnabled’ to be true.
    Then I made Context-menu with buttons of ‘undo’ and ‘redo’, but nothing happened when I click it after making a few changes at the diagram. (no errors also).

  2. another thing, before the moving to gojs-angular library, I was saved the diagram at my db in that way:
    data = JSON.parse(myDiagram.model.toJson());

but now, I am getting error of ‘maximum call stack size exceeded’.
what is the way to extract to necessary data from the diagram obj for saving at db?

thank you!

Which version of gojs-angular are you using?

Do you need to call JSON.parse(myDiagram.model.toJson())? That seems an inefficient way to make a copy of a bunch of model data.

I’m guessing that you have added some circular data references in the model data. Look carefully at each of the Model.nodeDataArray and GraphLinksModel.linkDataArray objects to make sure they have no shared or cyclical references.

I am using the latest version of gojs-angular, 1.0.3.

I am not sure that is the best way for saving the data. do you have mabe example in angular for saving the diagram data for reuse?
If I will save only nodeDataArray and linkDataArray, that will be enough?

I can not find any cyclic data, unfortunately.

and the last thing, do you have any idea about the undo manager? why it does not take any effect?


I just do not see how calling JSON.parse helps save anything.

Yes, saving and loading the data in those two Arrays is usually sufficient. Could you please show the result of calling JSON.stringify(myDiagram.model.nodeDataArray)? You can truncate the output after the first couple node data objects.

Thank you walter.

I succeeded to solve the problem of the‘maximum call stack size exceeded’ by remove ‘[modelData]=‘diagramModelData’’ from the html template. I took this property from the basic example without use it. now I am also just saving the nodeDataArray and linkDataArray only in my db.

but now, I am still stuck with the undo manager that not works. do you have any idea how to figure out the problem?

I just tried adding a context menu with undo / redo buttons on the gojs-angular-basic sample, which uses gojs-angular 1.0.3, and it works fine.

My best guess is you are not setting the skipsDiagramUpdate flag (added with 1.0.3) to true on your diagramModelChange function. Is that so? You can read a bit more on how skipsDiagramUpdate works here, and/or see how/when it is being set in the aforementioned gojs-angular-basic sample

If you have set this, can you please give me a minimal sample so I can help find the problem?

Hi ryanj, you were right, I missed that flag. now it works. thank you!!