本文整理匯總了TypeScript中angular2/http.URLSearchParams.append方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript URLSearchParams.append方法的具體用法?TypeScript URLSearchParams.append怎麽用?TypeScript URLSearchParams.append使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類angular2/http.URLSearchParams
的用法示例。
在下文中一共展示了URLSearchParams.append方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: urlEncode
export function urlEncode(obj: Object): string {
let urlSearchParams = new URLSearchParams();
for (let key in obj) {
if (0)
urlSearchParams.append(key, urlEncode(obj[key]))
else {
urlSearchParams.append(key, obj[key]);
}
}
return urlSearchParams.toString();
}
示例2: URLSearchParams
export const objToSearchParams = (obj:any):URLSearchParams => {
let params = new URLSearchParams();
for (let k in obj) {
if(obj[k]) params.append(k, obj[k]);
}
return params;
};
示例3: toParamsString
export function toParamsString(params: any) {
let urlSearchParams = new URLSearchParams();
for (let key in params) {
urlSearchParams.append(key, params[key]);
};
return urlSearchParams.toString();
}
示例4: searchByCoords
searchByCoords(latitude: number, longitude: number, page: number = 1) : Observable<any> {
let searchParams: URLSearchParams = new URLSearchParams();
searchParams.append("country", "uk");
searchParams.append("pretty", "1");
searchParams.append("action", "search_listings");
searchParams.append("encoding", "json");
searchParams.append("listing_type", "buy");
searchParams.append("page", page.toString());
searchParams.append("centre_point", "" + latitude + "," + longitude);
const response: Observable<Response> = this._http.get(Config.apiUrl, { search: searchParams });
return response.map(res => res.json()).map(
data => data.response
);
}
示例5: search
search(location: string, page: number = 1) : Observable<any> {
let searchParams: URLSearchParams = new URLSearchParams();
searchParams.append("country", "uk");
searchParams.append("pretty", "1");
searchParams.append("action", "search_listings");
searchParams.append("encoding", "json");
searchParams.append("listing_type", "buy");
searchParams.append("page", page.toString());
searchParams.append("place_name", location);
const response: Observable<Response> = this._http.get(Config.apiUrl, { search: searchParams });
return response.map(res => res.json()).map(
data => data.response
);
}
示例6: createUrlSearchParams
static createUrlSearchParams(select: string, orderBy: string, expand: string, filter: string, top: number, skip: number, count: boolean): URLSearchParams {
let urlSearchParams = new URLSearchParams();
if (select)
urlSearchParams.set('$select', select);
if (orderBy)
urlSearchParams.set('$orderby', orderBy);
if (expand)
urlSearchParams.set('$expand', expand);
if (filter)
urlSearchParams.set('$filter', filter);
if (top)
urlSearchParams.set('$top', top.toString());
if (skip)
urlSearchParams.set('$skip', skip.toString());
if (count)
urlSearchParams.append('$count', 'true');
return urlSearchParams;
}
示例7: deleteTodo
deleteTodo(deletedTodo: Todo) {
let params = new URLSearchParams();
params.append('id', '' + deletedTodo.id );
return this.http.delete('/todo', {search: params});
}
示例8: deletePhoto
deletePhoto(deletedPhoto: any) {
let params = new URLSearchParams();
params.append('id', '' + deletedPhoto.id );
return this.http.delete(this.base_url, {search: params});
}
示例9: deleteComment
deleteComment(deletedComment: any) {
let params = new URLSearchParams();
params.append('id', '' + deletedComment.id );
return this.http.delete(this.base_url, {search: params});
}