如何將一個新行按下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