Is there a way to insert a new row into a table using ng-click? I currently have the following setup with the data stored in an array.
Here is how my array looks.
$scope.workflows = [{
Id: 1,
Name: "Workflow Page 1",
Description: "Describe Workflow",
Steps: [{
Id: 1,
Name: "name me",
Description: "describe me",
Action: "do something",
Obj: "whats the goal",
AdditionalInfo: "anything else",
}, {
Id: 2,
Name: "name me",
Description: "describe me",
Action: "do something",
Obj: "whats the goal",
AdditionalInfo: "anything else",
},
]},
}, ];
This is the new data that I want to add to my array and here's how I am attempting to do it using $scope.
$scope.addStep = function(newStep) {
$scope.newStep = [{
Id: 0,
Name: "Step on THIS!",
Description: "I dare ya!",
Action: "STOMP!",
Obj: "A Rock",
AdditionalInfo: "I am bleeding...",
}]
$scope.workflows.push(newStep);
alert("test :" + "Its GON WORK");
};
In the HTML, I trigger the addStep function using ng-click, hoping it will add a new row to my table.
<div class="text" ng-click="addStep(newStep)"> + Click to Add a New Step</div>
Thank you!