Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* UPDATE PRODUCT */
- Products.findByIdAndUpdate(req.params.id, req.body, function (err, post) {
- if (err) return next(err);
- res.json(post);
- });
- });
- onSaveConfirm(event) {
- if (window.confirm('Are you sure you want to save?')) {
- var prodId=event.newData['_id']
- this.productService.productUpdate(event.newData, prodId).subscribe(data => {
- if (data.success) {
- console.log('Edited success')
- } else {
- console.log('failure edited...')
- }
- });
- event.confirm.resolve(event.newData);
- } else {
- event.confirm.reject();
- }
- }
- //Update product based on id
- productUpdate(products, prodId){
- let prodDet = {
- productDetail: products,
- productId: prodId,
- }
- let headers = new Headers();
- headers.append('Content-Type', 'application/json');
- return this.http.post('http://localhost:5000/products', { prodDet }, { headers: headers })
- .map(res => res.json());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement