我有这个玉文件:
<tbody>
<tr ng-repeat="lineas in datuak">
<td class="tdlinea">Linea:{{ lineas.linea }}</td>
<td data-ng-repeat="nireindex in [0,1,2,3,4,5,6]">
<table class="table text-center table-condensed">
<thead>
<th>Mañana</th>
<th>Tarde</th>
<th>Noche</th>
</thead>
<tbody>
<tr>
<td>
<table>
<tr ng-repeat="orden in lineas.egunak[nireindex].turnoak[0].ordenes" ng-if="checkStatus(lineas.egunak[nireindex].fetxa,nireindex)">
<td style="background-color: {{ mysettings | searchByRefBackcolor : 'ref' : orden.ref }} !important; color:{{ mysettings | searchByRefForecolor : 'ref' : orden.ref }} !important;">
<span editable-text="orden.ref" onbeforesave="updateUser($data)">{{ orden.ref }}</span><span editable-text="orden.of">{{ orden.of }}</span>
</td>
</tr>
</table>
</td>
<td>
<table>
<tr ng-repeat="orden in lineas.egunak[nireindex].turnoak[1].ordenes" ng-if="checkStatus(lineas.egunak[nireindex].fetxa,nireindex)">
<td style="background-color: {{ mysettings | searchByRefBackcolor : 'ref' : orden.ref }} !important; color:{{ mysettings | searchByRefForecolor : 'ref' : orden.ref }} !important;">{{ orden.ref }} {{ orden.of }}</td>
</tr>
</table>
</td>
<td>
<table>
<tr ng-repeat="orden in lineas.egunak[nireindex].turnoak[2].ordenes" ng-if="checkStatus(lineas.egunak[nireindex].fetxa,nireindex)"><td style="background-color: {{ mysettings | searchByRefBackcolor : 'ref' : orden.ref }} !important; color:{{ mysettings | searchByRefForecolor : 'ref' : orden.ref }} !important;">{{ orden.ref }} {{ orden.of }}</td></tr>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr> <!-- lineas -->
</tbody>
当我要更新此字段时,我使用http://vitalets.github.io/angular-xeditable/实现了onclick编辑功能,所有工作都很好。
我的数据库是mongodb,看起来像这样:
[
{
"linea": 1,
"egunak": [
{
"fetxa": "2014/05/26",
"turnoak": [
{
"turno": 1,
"ordenes": [
{
"ref": "3CI00001"
},
{
"of": "OF000013"
}
]
},
{
"turno": 2,
"ordenes": [
{
"ref": "3CI00001"
},
{
"of": 112233
},
{
"ref": "3CI00001"
}
]
},
{
"turno": 3,
"ordenes": [
{
"ref": "3CI00001"
}
]
}
]
},
{
"fetxa": "2014/05/27"
},
{
"fetxa": "2014/05/28",
"turnoak": [
{
"turno": 1,
"ordenes": [
{
"ref": "3CI00001"
},
{
"of": "OF200013"
}
]
},
{
"turno": 2,
"ordenes": [
{
"ref": "3CI00001"
},
{
"of": "OF232233"
},
{
"of": "OF289977"
}
]
},
{
"turno": 3,
"ordenes": [
{
"ref": "3CI00001"
},
{
"of": "OF200000"
},
{
"ref": "3CI00001"
},
{
"of": "OF200000"
},
{
"ref": "3CI00001"
}
]
}
]
},
{
"fetxa": "2014/05/29"
},
{
"fetxa": "2014/05/30"
},
{
"fetxa": "2014/05/31"
},
{
"fetxa": "2014/06/01"
}
]
},
{
"linea": 2,
"egunak": [
{
"fetxa": "2014/05/26"
},
{
"fetxa": "2014/05/27",
"turnoak": [
{
"turno": 1,
"ordenes": [
{
"ref": "3CI00002"
},
{
"of": "2OF000013"
}
]
},
{
"turno": 2,
"ordenes": [
{
"ref": "3CI00001"
},
{
"of": "2OF2233"
},
{
"ref": "3CI00001"
}
]
},
{
"turno": 3,
"ordenes": [
{
"ref": "3CI00001"
}
]
}
]
},
{
"fetxa": "2014/05/28"
},
{
"fetxa": "2014/05/29",
"turnoak": [
{
"turno": 1,
"ordenes": [
{
"ref": "3CI00001"
},
{
"of": "2OF200013"
}
]
},
{
"turno": 2,
"ordenes": [
{
"ref": "3CI00001"
},
{
"of": "2OF232233"
},
{
"ref": "3CI00001"
}
]
},
{
"turno": 3,
"ordenes": [
{
"ref": "3CI00001"
},
{
"of": "2OF200000"
},
{
"ref": "3CI00001"
},
{
"of": "2OF200000"
},
{
"ref": "3CI00001"
}
]
}
]
},
{
"fetxa": "2014/05/30"
},
{
"fetxa": "2014/05/31"
},
{
"fetxa": "2014/06/01"
}
]
}
]
如何更新示例linea:1 =&gt; fetxa:“2014/05/26”=&gt; turno:2 =&gt; ref:“3CI00001”(第二个)ref:3CI00002?
答案 0 :(得分:0)
来自示例http://vitalets.github.io/angular-xeditable/的controller.js可编辑表
$scope.saveTable = function() {
var results = [];
for (var i = $scope.users.length; i--;) {
var user = $scope.users[i];
// ...
// send on server
results.push($http.post('/saveUser', user));
}
return $q.all(results);
};
});
如您所见,每个用户都在服务器端保存了所有用户字段。最简单的方法是在服务器端更新完整对象,而无需为少数字段构建更新查询。