嗨,我想发布具有相同型号名称的所有表单数据.这是我的代码,我也克隆tr标签创建更多具有相同名称类和形式的表格.型号.
像这样的角度代码
$scope.saveJob = function(data) {
console.log(data);
//http request goes here
}
最佳答案
您可以使用数组和ng-repeat来实现此功能,而不是克隆html元素.
HTML
角度控制器
// You can fetch this array of jobs from server for showing purpose
$scope.jobs = [
{
quantity: "1.0",quality: "A"
},{
quantity: "2.0",quality: "B"
}
]
$scope.clone = function(){
// You can change default values for new job to appear
var empty = {
quantity: "",quality: ""
};
$scope.jobs.push(empty);
}
$scope.save = function(){
// You can send this array of jobs to server for saving purpose
console.log($scope.jobs);
}
猜你在找的JavaScript相关文章