0
後、JSONに新しいオブジェクトを作成します。これは次のようになります:は、クリック(http.put)私は次のようなJSON構造をしている
"disputas": [
{
id: "",
tipo_negociacao: "",
historico:{
fl_usuario: "",
created_at: "",
updated_at: "",
created_by: null,
updated_by: null,
texto: "",
},
historico:{
fl_usuario: "",
created_at: "",
updated_at: "",
created_by: null,
updated_by: null,
texto: "",
}
}
]
どうすればいいですか?
これは私のサービスです。事前に
url: string = 'http://localhost:3004/disputa';
constructor(private http: Http){}
atualizaDisputa (body:Object): Observable<DisputaPropostaComponent[]>{
let bodyString = JSON.stringify(body); // Stringify payload
let headers = new Headers({ 'Content-Type': 'application/json' }); // ... Set content type to JSON
let options = new RequestOptions({ headers: headers }); // Create a request option
return this.http.put(`${this.url}/${body['id']}`, body, options) // ...using post request
.map((res:Response) => res.json()) // ...and calling .json() on the response to return data
.catch((error:any) => Observable.throw(error.json().error || 'Ocorreu um erro em nosso servidor, tente novamente mais tarde')); //...errors if any
}
感謝。あなたにもっとコードが必要な場合は教えてください。
質問が不明です。ヒストリカル::{ fl_usuario: ""、 はcreated_at: ""、 updated_atの: ""、 CREATED_BY:ヌル、 updated_by:ヌル、 TEXTO: ""、 } あなたはのようなものを作成したいですボタンを押すと? –
私はちょうど今質問を編集しました、私はそれが少しはっきりしていると思います –
オブジェクトにhistoricoという名前の2つのキーを持つことはできません。それを配列に変換する必要があります。いったんこれを行うと、いつものように配列にプッシュすることができます。 –