I have this jade file:
<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>
And I implemented onclick edit feature with http://vitalets.github.io/angular-xeditable/ all workf fine instead when I´m going to update this field.
My database is in mongodb and looks like this:
[
{
"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"
}
]
}
]
How can I update for example linea:1 => fetxa: "2014/05/26" => turno:2 => ref :"3CI00001" (the second one) to ref:3CI00002 ?
controller.js from example http://vitalets.github.io/angular-xeditable/ for Editable table
$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);
};
});
As you can see, each user saved on server side with all user fields. The easiest way is update full object on server side without building update query for few fields.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.