本文整理匯總了TypeScript中@angular/http.Http.put方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Http.put方法的具體用法?TypeScript Http.put怎麽用?TypeScript Http.put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@angular/http.Http
的用法示例。
在下文中一共展示了Http.put方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: updateSchedule
updateSchedule(schedule: Schedule) : Observable<any> {
let url = global.url + "api/Schedules/" + schedule.Id;
let body = JSON.stringify(schedule);
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
return this.http.put(url, body, options)
.catch(this.handleError);
}
示例2: updateSingleNews
updateSingleNews(news: News) : Observable<any> {
let url = global.url + "api/News/" + news.Id;
let body = JSON.stringify(news);
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
return this.http.put(url, body, options)
.catch(this.handleError);
}
示例3: put
/**
* Wrapper for HTTP PUT operation
*/
public put(url: string, body?: string): Observable<any> {
this._headers.set("Content-Type", "application/json");
const options = new RequestOptions({headers: this._headers});
if (body === null) {
body = "";
}
return this._http
.put(this._baseUrl + url, body, options)
.map(response => this.mapResponse(response))
.catch(error => this.handleError(error));
}
示例4: updateDivision
updateDivision(division: Division) : Observable<any> {
let url = global.url + "api/Divisions/" + division.Id;
let body = JSON.stringify(division);
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
return this.http.put(url, body, options)
.catch(this.handleError);
}
示例5: updatePlayer
updatePlayer(player: Player): any {
let url = CONFIG.apiUrl + '/players/' + player.playerId;
let body = JSON.stringify(player);
let headers = new Headers({'Content-Type': 'application/json'});
let options = new RequestOptions({headers: headers});
return this.http.put(url, body, options)
.map(res => res.json()[0])
.catch(this.helperService.handleError);
}
示例6: modifyCustomer
modifyCustomer(customer: Customer): Promise<User> {
let body = JSON.stringify({ customer });
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
return this.http.put('api/customer', body, options)
.toPromise()
.then(response => {
return response.json();
})
.catch(this.handleError);
}
示例7: updateOrganization
updateOrganization(organization: Organization) {
let headers = this.getHeaders();
// don't send userId as a parameter. The server validates the userId from the token in the header.
let url = ROOT + '/Organization/Update';
this.http.put(url, organization, { headers: headers })
.subscribe((response: Response) => {
this.cacheService.put(this.cacheKeys.Organization, null);
this.emit(ServiceEvents.OrganizationUpdated);
});
}
示例8: setPass
setPass(body: string, idUser: number, token): Observable<any> {
const url = `${this.urlRecover }`;
const headers = new Headers();
headers.append('Content-Type', 'application/json');
headers.append('Authorization', `Bearer ${token}`);
const options = new RequestOptions({headers: headers, withCredentials: true});
return this.http
.put(url, body, options)
.map(this.extractData)
.catch(this.extractData);
}
示例9: stopTrip
public stopTrip(trip:ITrip):Observable<ITrip> {
console.log('stopping');
console.log(JSON.stringify(trip));
console.log(trip);
console.log('done stopping');
var headers = new Headers();
trip.tripStatus = Trip.TRIP_STATUS_STOPPED;
headers.append('Content-Type', 'application/json');
return this.http.put(environment.API + '/trips/' + trip.id, JSON.stringify(trip), {headers: headers})
.map(res => res.json());
}
示例10: updateStudents
updateStudents(code: string, students: string[]) {
return this.http.put("/api/subject/" + code + "/students", JSON.stringify({students: students}), {
headers: authHeaders()
}).map((res) => {
if (res.status === 200) {
return true;
} else {
return false;
}
});
}