I am trying to update a value in a column in sql server, for that I use sequelize to access my database. I manage to do it using nodejs and when I send the right url in postman , it works, but what I want is to access it via my frontend using my service and controller, so far it does not work because I don't know how to pass the updated data : here is my code :
My back-end :
//update the "estArchive" property to move project to archive liste"
router.put('/projets/:id',function(req,res){
projet.Projet.find({ where: { IdProjet: req.params.id } }).then(function (project) {
// Check if record exists in db
if (project) {
project.updateAttributes({
estArchive: req.body.estArchive
})
res.json({success:true, message: 'Projet modifié', projetsListe: project});
}
else
res.json({success:false, message: 'aucun projet avec cette id trouvé'});
})
})
This part is working and it updates the estArchive
value (datatype : Boolean)
Now here is my service :
// update the estArchive functionnality :
archiveprojet : function(id_Data,updateData){
return $http.put('/api/projets/' + id_Data,updateData);
}
And This is my controller :
.controller('projetsCtrl',function ($http,Projet,Client,$scope,$q,$route,$location){
var app=this;
app.Archive=function(id){
app.updateData.estArchive="true";
Projet.archiveprojet(id,app.updateData);
};
And this is my view I want to be able to update the column estArchive
when clicking on the button :
<td><button type="button" class="btn btn-danger btn-sm" ng-click="projetsCtrl.Archive(projet.IdProjet)"><i class="fa fa-archive"></i> Archiver ce projet ?</button></td>
when clicking on that button I want estArchive
value to be updated to true
, I used these same steps for post and get and it's working, but here It's not, what am I doing wrong ? (sorry for the long post)
via jihane
No comments:
Post a Comment