2
私は、PUTメソッドのURLがメモリのWeb APIでどのように構築されるのか、app/commentList/0とします。ここでは0はcommentListのコメントIDです。サービスのPUTメソッド用にangular2-in-memory-web-apiでURLを作成するにはどうすればよいですか?
サンプルコード:DBの
updateComment(data: any):Observable<any>{
const url = `${this.dataUrl}/${data.id}`;
return this.http.put(url, JSON.stringify(data), this.options)
.map(res => console.log(res))
}
サンプルコード:
import { InMemoryDbService } from 'angular2-in-memory-web-api';
export class CommentsData implements InMemoryDbService {
createDb() {
let commentList = [
{ id:1, username: 'abc', comment: 'adfasdfasdf' },
{ id:2, username: 'rty', comment: 'qwerqewr' },
{ id:3, username: 'Zaw', comment: 'poiqwer' },
{ id:4, username: 'weew', comment: 'asdflkjmasd' }
];
return {commentList};
}
}
updateComment()方法では、私はちょうど、どのような場合は、idパラメータでURLを打つが、よ私は '名前'のように、任意の異なるパラメータを渡したいですか?