I am trying to convert this function for drawing the shapes from
X-JSRENDER to
NG-TEMPLATE. I am able to draw the shapes and everything works fine but I am unable to assign different
NG-MODEL values for the fields every time when I create them. Due to which when I make changes to one NODE field then all the other NODES with same field are getting the same values. As most part of my application is in Angularjs I would like this also to be in
AngularJS. Also, I need to populate the
SELECT field from
DATABASE and the values are present within $SCOPE variable, if I use
X-JSRENDER then I won't be able to access my
$SCOPE variable within X-JSRENDER.
Here is the complete code:
https://jsfiddle.net/B_AV_B/39w42onm/18/
//Add the Node on Drag and Drop
$scope.NodeAdd = function()
{
$scope.diagram = angular.element("#diagram").ejDiagram("instance");
var ports = [{name:"port1",offset:{x:0,y: 0.5},shape: "circle"},{name:"port2",offset:{x: 1,y: 0.5},shape: "circle"},{name:"port3",offset:{x:0.5,y:0},shape: "circle"},{name:"port4",offset:{x:0.5,y:1},shape: "circle"}];
var name = "Event"+nodeCounter;
var label = [{text:name ,offset:{x: 0.5,y: 0.1 }}];
$scope.diagram .model.drawType = {
type : "html",
name : name,
templateId : "htmlTemplate",
labels : label,
ports : ports,
value : {
text : "text"+Number(nodeCounter),
select : "BusinessStep"+Number(nodeCounter)
}
};
var tool = $scope.diagram.tool();
$scope.diagram.update({ tool: tool | ej.datavisualization.Diagram.Tool.DrawOnce });
nodeCounter++;
}
//on change of the text field get the values and populate in Node addinfo
$scope.change = function(){
console.log('Within Text Change');
var diagram = angular.element("#diagram").ejDiagram("instance");
var node = diagram.selectionList[0];
var text = diagram.model.drawType.value.text;
node.addInfo.value = text;
console.log(node);
}
//on change of the Select fied get the values and populate in Node addinfo
$scope.SelectField = function(){
console.log('Within Select Change');
var diagram = angular.element("#diagram").ejDiagram("instance");
var node = diagram.selectionList[0];
var select = diagram.model.drawType.value.select;
node.addInfo.value = select;
console.log(node);
}
I tried couple of things such as ng-repeat but it would repeat the node again and again.I tried adding the value as ARRAY instead of OBJECT when creating the node as mentioned in another answer but that also would not work.
If you could give me some idea or guidance then it would be really great. Thanks a lot.