Greetings, I am creating an editing environment for use cases, I use the FabricJS library. To create the elements of the diagram I use the following code: (I use images)
var canvas = new fabric.Canvas('pizarra');
var HideControls = {
'tl':true,
'tr':false,
'bl':true,
'br':true,
'ml':true,
'mt':true,
'mr':true,
'mb':true,
'mtr':true
};
$("#actor").on("click", function(e) {
fabric.Image.fromURL('app-content/icons/actor.svg', function (img) {
img.top = 60;
img.left = 30;
img.width = 31;
img.height = 70;
img.setControlsVisibility(HideControls);
canvas.add(img);
});
});
$("#CU").on("click", function(e) {
fabric.Image.fromURL('app-content/icons/CU.svg', function (img) {
img.top = 60;
img.left = 30;
img.width = 130;
img.height = 60;
canvas.add(img);
});
});
Next, I create the save () function that converts the diagram elements into JSON code:
function save() {
var data = canvas.toJSON();
var string = JSON.stringify(data);
//JSON en array
//console.log(data.objects);
//cadena de texto
console.log(string);
//return data.objects;
}
My question is this: I need to get the JSON created in the save () function in the angle controller, I would like to know if there is any way to do this?
Thank you very much.