【问题标题】:how i can use update service with restangular2我如何使用 restangular2 的更新服务
【发布时间】:2017-06-14 09:04:33
【问题描述】:

你好,我正在使用 restangular 在我的 angular2 应用程序中创建一个编辑服务 这是我的服务

import {Injectable} from '@angular/core';
import {Project} from '../model/projects';
import {id} from "@swimlane/ngx-datatable/release/utils";
import {Restangular} from 'ngx-restangular';

@Injectable()
export class updateprojectService {
project: Project;
constructor (private restangular: Restangular) {}
update(project) {
return this.restangular.one('projects').customPUT(project,{'projectid': project.id}, undefined, {'Content-Type': undefined});

}
}

这是错误

也许问题是指定要编辑的数据的 id

【问题讨论】:

    标签: angular restangular


    【解决方案1】:

    看起来你的project.id 是一个对象而不是一个数字。把它倒出来,看看这个数字在什么参考下。像

    ...
    return this.restangular.one('projects').customPUT(project,{'projectid': project.id.some_key}, undefined, {'Content-Type': undefined}); 
    

    其中some_key 是未知对象引用。

    【讨论】:

      猜你喜欢
      • 2011-07-16
      • 1970-01-01
      • 2019-12-31
      • 2019-02-06
      • 1970-01-01
      • 2020-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多