如何将一个新行按下ng点击的方式推向表格? 这是我目前的。信息在一个数组中。用新角度在表格上点击新角度
我的数组看起来像这样。
$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",
},
]},
}, ];
这就是我想要添加到我的数组以及我如何使用范围来尝试添加它。
$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");
};
然后在HTML中,我使用ng-click来激活newStep函数,希望它在我的表中创建一个新行。
<div class="text" ng-click="addStep(newStep)"> + Click to Add a New Step</div>
谢谢!
使用'console.log'或角度的$ log来调试,而不是'alert'进行调试。 – Lekhnath 2014-12-04 18:33:58