本文整理汇总了TypeScript中@angular/http.URLSearchParams.toString方法的典型用法代码示例。如果您正苦于以下问题:TypeScript URLSearchParams.toString方法的具体用法?TypeScript URLSearchParams.toString怎么用?TypeScript URLSearchParams.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/http.URLSearchParams
的用法示例。
在下文中一共展示了URLSearchParams.toString方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: urlEncode
private urlEncode(obj: any): string {
let urlSearchParams = new ngURLSearchParams('', new TrueQueryEncoder());
for (let key in obj) {
urlSearchParams.append(key, obj[key]);
}
return urlSearchParams.toString();
}
示例2: urlEncode
urlEncode(obj:Object):string {
let urlSearchParams = new URLSearchParams();
for (let key in obj) {
urlSearchParams.append(key, obj[key]);
}
return urlSearchParams.toString();
}
示例3: query
query(base: string, options?: Object) : string {
if (!options) return base;
var params = new URLSearchParams();
for (var key in options) {
params.set(key, String(options[key]));
}
return base + "?" + params.toString();
}
示例4: post
post(username: string, password: string): Observable<UserModel> {
const body = new URLSearchParams('', new PatchedQueryEncoder());
body.append('username', username);
body.append('password', password);
const options = this.httpOptions({ 'Content-Type': 'application/x-www-form-urlencoded' });
return this.http.post('/api/login', body.toString(), options)
.map(res => this.setUserFromResponse(res));
}
示例5: list
public list(factoryLink: string, queryOptions: any,
projectLink?: string): Promise<DocumentListResult> {
let params = new URLSearchParams();
// params.set('$limit', serviceUtils.calculateLimit().toString());
params.set('$limit', PAGE_LIMIT);
params.set('expand', 'true');
params.set('documentType', 'true');
params.set('$count', 'true');
if (queryOptions) {
let filter = getFilter(queryOptions);
if(filter){
params.set('$filter', filter);
}
}
let op;
// 2000 is th max url length. Here we don't know the hostname, so 50 chars extra
if (params.toString().length + factoryLink.length > 1950) {
let data = {
uri: factoryLink + '?' + params.toString()
};
factoryLink = Links.LONG_URI_GET;
op = this.post(factoryLink, data);
} else {
op = this.ajax.get(factoryLink, params, undefined, this.buildHeaders(projectLink));
}
return op.then(result => {
let documents = result.documentLinks.map(link => {
let document = result.documents[link];
document.documentId = Utils.getDocumentId(link);
return document;
});
return new DocumentListResult(documents, result.nextPageLink, result.totalCount);
}).then(result => slowPromise(result));
}
示例6: signIn
// Submit signin form to backend (NOT restful service)
signIn(signInCredential: SignInCredential): Observable<any> {
// Build the form package
const body = new URLSearchParams();
body.set('principal', signInCredential.principal);
body.set('password', signInCredential.password);
// Trigger Http
return this.http.post(signInUrl, body.toString(), HTTP_FORM_OPTIONS)
.pipe(map(() => null)
, catchError(error => observableThrowError(error)));
}
示例7: urlEncode
protected urlEncode(obj: Object): string {
let urlSearchParams = new URLSearchParams();
for (let key in obj) {
if (!obj.hasOwnProperty(key) || obj[key] === undefined) {
continue;
}
urlSearchParams.append(key, obj[key]);
}
return urlSearchParams.toString();
}
示例8: signIn
// Submit signin form to backend (NOT restful service)
signIn(signInCredential: SignInCredential): Promise<any> {
// Build the form package
const body = new URLSearchParams();
body.set('principal', signInCredential.principal);
body.set('password', signInCredential.password);
// Trigger Http
return this.http.post(signInUrl, body.toString(), HTTP_FORM_OPTIONS)
.toPromise()
.then(() => null)
.catch(this.handleError);
}
示例9: getQueryString
getQueryString () {
var params = new URLSearchParams('');
if (!!this.urlParams) {
for (var key in this.urlParams) {
params.set(key, this.urlParams[key].id ? this.urlParams[key].id : this.urlParams[key]);
}
}
params.set('username', this.username);
params.set('api_key', this.api_key);
params.set('format', 'json');
return params.toString();
}
示例10: resetPassword
resetPassword(uuid: string, newPassword: string): Observable<any> {
if (!uuid || !newPassword) {
return observableThrowError("Invalid reset uuid or password");
}
let body: URLSearchParams = new URLSearchParams();
body.set("reset_uuid", uuid);
body.set("password", newPassword);
return this.http.post(resetPasswordEndpoint, body.toString(), HTTP_FORM_OPTIONS)
.pipe(map(response => response)
, catchError(error => observableThrowError(error)));
}