Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. /* UPDATE PRODUCT */
  2. Products.findByIdAndUpdate(req.params.id, req.body, function (err, post) {
  3. if (err) return next(err);
  4. res.json(post);
  5. });
  6. });
  7.  
  8. onSaveConfirm(event) {
  9. if (window.confirm('Are you sure you want to save?')) {
  10. var prodId=event.newData['_id']
  11.  
  12. this.productService.productUpdate(event.newData, prodId).subscribe(data => {
  13. if (data.success) {
  14. console.log('Edited success')
  15. } else {
  16. console.log('failure edited...')
  17. }
  18. });
  19. event.confirm.resolve(event.newData);
  20. } else {
  21. event.confirm.reject();
  22. }
  23.  
  24. }
  25.  
  26. //Update product based on id
  27. productUpdate(products, prodId){
  28.  
  29. let prodDet = {
  30. productDetail: products,
  31. productId: prodId,
  32. }
  33.  
  34. let headers = new Headers();
  35. headers.append('Content-Type', 'application/json');
  36. return this.http.post('http://localhost:5000/products', { prodDet }, { headers: headers })
  37. .map(res => res.json());
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement