本文整理汇总了TypeScript中angular2/http.Http.put方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Http.put方法的具体用法?TypeScript Http.put怎么用?TypeScript Http.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angular2/http.Http
的用法示例。
在下文中一共展示了Http.put方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: saveStory
saveStory(userId, story:Story):Observable<Story> {
let headers = new Headers({
'Content-Type': 'application/x-www-form-urlencoded'
});
let options = new RequestOptions({
headers: headers
});
story.userId = userId;
if (!!story._id) {
story.createdAt = story.createdAt || (new Date());
story.lastModifiedAt = (new Date());
return this.http.put(this.configuration.apiBasePath + '/story/' + userId + '/'+ story._id , "data=" + JSON.stringify(story), options)
.map(res => res.json())
.catch(this.logger.errorCatcher());
}
else {
story.createdAt = (new Date());
story.lastModifiedAt = (new Date());
return this.http.post(this.configuration.apiBasePath + '/story/' + userId + '/', "data=" + JSON.stringify(story), options)
.map(res => res.json())
.catch(this.logger.errorCatcher());
}
}
示例2: getUseRestriction
getUseRestriction(questions: string): Observable<Response> {
let headers = new Headers();
headers.append('Content-Type', 'application/json');
return this.http.put(AppSettings.DAR_USERESTRICTION_ENDPOINT, questions, {
headers: headers
});
}
示例3: update
update(form: Form) {
return this._http.put(
Config.api('form/'+form.id),
JSON.stringify(form),
this.headers()
);
}
示例4: saveSelectionForComp
saveSelectionForComp(compId:String, selection:Selection):Observable<Response> {
// /auth/ URLs are protected by the middleware
return this._http.put(BASE_URL + '/auth/competition/selection/push/' + compId, JSON.stringify(selection), {
headers: json()
})
.share();
}
示例5: updatePerson
updatePerson(data: string, http: Http) {
var config = new Config();
let headers = new Headers({ 'Content-Type': 'application/json' });
var options = new RequestOptions({ headers: headers });
return http.put(config.apiBaseUrl + "People", data, options).toPromise();
};
示例6: saveBlog
saveBlog(blog: BlogEntry): Observable<Response> {
if (blog.id) {
return this.http.put('/api/blogs/' + blog.id, blog.json(), this.opts);
} else {
return this.http.post('/api/blogs', blog.json(), this.opts);
}
}
示例7: createRequest
private createRequest(type: string,data ?: Object) : Observable<any> {
let _url : string = this.buildUrl(data);
let _request : Observable<any>
let stringParam : string = '';
let _jsonBuild : any = {}
if(_url.split('?')[1] && _url.split('?')[1].length) {
(_url.split('?')[1].split('&')).forEach( _paramPart => {
_jsonBuild[_paramPart.split('=')[0]] = _paramPart.split('=')[1];
});
stringParam = JSON.stringify(_jsonBuild);
}
switch (type) {
case "post":
_request = this._http.post(_url.split('?')[0], stringParam);
break;
case "patch":
_request = this._http.patch(_url.split('?')[0], stringParam);
break;
case "put":
_request = this._http.put(_url.split('?')[0], stringParam);
break;
case "delete":
_request = this._http.delete(_url);
break;
case "head":
_request = this._http.head(_url);
break;
default:
_request = this._http.get(_url);
break;
}
this._request = _request.map((response: Response) => response.json());
return this._request;
}
示例8: updateGame
updateGame(game: Game) {
this.http.put(`${BASE_URL}/${game.id}`, JSON.stringify(game), HEADER)
.subscribe(
action => this.store.dispatch({ type: 'UPDATE_GAME', payload: game }),
error => console.log('Error: ' + error)
);
}
示例9: update
update(band: Band) {
return this._http.put(this.baseAPIUrl + 'band/' + band.id + '/', JSON.stringify({
name: band.name,
description: band.description
}), this.getHeaders())
.map(res => res.json())
}
示例10: addContenido
//AĂąadir contenido al usuario
addContenido(producto: Prod, usuario: Usuario){
usuario.coleccion.push(producto);
if(producto.tipoprod == 3){
usuario.nPelis = usuario.nPelis + 1;
}
if(producto.tipoprod == 2){
usuario.nSeries = usuario.nSeries + 1;
}
if(producto.tipoprod == 1){
usuario.nJuegos = usuario.nJuegos + 1;
}
let cambio = JSON.stringify(usuario);
let headers = new Headers({
'Content-Type': 'application/json',
'X-Requested-With': 'XMLHttpRequest'
});
let options = new RequestOptions({headers});
return this.http.put(BASE_URL + usuario.id, cambio, options)
.map(
response => response.json()
)
.catch(
error => this.handleError(error)
);
}