本文整理汇总了TypeScript中@angular/http.URLSearchParams类的典型用法代码示例。如果您正苦于以下问题:TypeScript URLSearchParams类的具体用法?TypeScript URLSearchParams怎么用?TypeScript URLSearchParams使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了URLSearchParams类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: Headers
import { Injectable } from '@angular/core';
import { Http, Headers, RequestOptions, Response, URLSearchParams } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/throw';
const baseUrl = 'https://api.mlab.com/api/1/databases/reits/collections';
const apiKey = 'EhpBOdclXrepXAuPKpXeijpuT19p2peh';
const headers = new Headers({ 'Content-Type': 'application/json' });
const params = new URLSearchParams();
params.set('apiKey', apiKey);
const options = new RequestOptions({
headers: headers,
search: params
});
const jsonResponse = ((response: Response) => response.json());
const jsonError = (error: Response) => {
const json = error.json();
json['status'] = error.status;
return Observable.throw(json);
};
@Injectable()
export class ApiService {
constructor(private http: Http) {}
get(url: string): Observable<Response> {
示例2: outlier
outlier(configuration, inputs, cube) {
const that = this;
const body = new URLSearchParams();
if (configuration.name === 'LOF_AGGREGATE') {
body.set('BABBAGE_AGGREGATE_URI', inputs['BABBAGE_AGGREGATE_URI']);
} else {
body.set('BABBAGE_FACT_URI', inputs['BABBAGE_FACT_URI']);
}
return that.http.get(configuration.endpoint.toString(), {search: body}).map(res => {
return res.json();
}).mergeMap(resp => {
const headersAdditional = new Headers;
headersAdditional.append('Cache-control', 'no-cache');
headersAdditional.append('Cache-control', 'no-store');
headersAdditional.append('Expires', '0');
headersAdditional.append('Pragma', 'no-cache');
return this.http.get(environment.DAMUrl + '/results/' + resp.jobid, {'headers': headersAdditional})
.map(res => {
const response = res.json();
if (!response.hasOwnProperty('result')) {
throw new Error('ex');
}
if (configuration.name === 'LOF_FACTS' || configuration.name === 'LOF_AGGREGATE') {
const values: any = response.result.result;
return {values: values};
} else {
const values: any = response.result;
const new_values = [];
const mappings = {};
Object.keys(values[0]).forEach(function (key) {
mappings[key] = key;
cube.model.dimensions.forEach(function (dimension) {
dimension.significants.forEach(function (attribute) {
if (key === (dimension.ref + '_' + attribute.shortRef).toLowerCase()) {
mappings[key] = attribute.ref;
}
});
});
cube.model.measures.forEach(function (measure) {
if (key === (measure.ref).toLowerCase()) {
mappings[key] = 'Target';
}
})
});
values.forEach(function (value) {
const new_value = {};
Object.keys(value).forEach(function (key) {
new_value[mappings[key]] = value[key];
});
new_values.push(new_value);
});
return {values: new_values};
}
}).retryWhen(function (attempts) {
return Observable.range(1, environment.DAMretries).zip(attempts, function (i) {
return i;
}).flatMap(function (i) {
console.log('delay retry by ' + i + ' second(s)');
if (i === environment.DAMretries) {
return Observable.throw(new JobTimeoutException);
}
return Observable.timer(i * environment.DAMpollingInitialStep);
});
});
});
}
示例3: timeseries
timeseries(configuration, inputs) {
const that = this;
const body = new URLSearchParams('', new PureURIEncoder());
body.set('amount', '\'' + inputs['amount'] + '\'');
body.set('time', '\'' + inputs['time'] + '\'');
body.set('prediction_steps', inputs['prediction_steps']);
body.set('json_data', '\'' + (inputs['json_data']) + '\'');
return that.http.post(configuration.endpoint.toString(), body).map(res => {
const response = res.json();
const forecasts = response['forecasts'];
const values: any = [];
for (let i = 0; i < forecasts.data_year.length; i++) {
values.push({
year: parseInt(forecasts.data_year[i], 10),
amount: parseFloat(forecasts.data[i])
});
}
for (let i = 0; i < forecasts.predict_time.length; i++) {
const val: any = {
year: parseInt(forecasts.predict_time[i], 10),
amount: parseFloat(forecasts.predict_values[i])
};
if (!isNaN(forecasts.up80[i])) {
val.up80 = parseFloat(forecasts.up80[i]);
}
if (!isNaN(forecasts.up95[i])) {
val.up95 = parseFloat(forecasts.up95[i]);
}
if (!isNaN(forecasts.low80[i])) {
val.low80 = parseFloat(forecasts.low80[i]);
}
if (!isNaN(forecasts.low95[i])) {
val.low95 = parseFloat(forecasts.low95[i]);
}
values.push(val);
}
const acfRegular = response['acf.param']['acf.parameters'];
const acfValues = [];
for (let i = 0; i < acfRegular['acf.lag'].length; i++) {
acfValues.push({
lag: parseFloat(acfRegular['acf.lag'][i]),
correlation: parseFloat(acfRegular['acf'][i])
});
}
const pacfRegular = response['acf.param']['pacf.parameters'];
const pacfValues = [];
for (let i = 0; i < pacfRegular['pacf.lag'].length; i++) {
pacfValues.push({
lag: parseFloat(pacfRegular['pacf.lag'][i]),
correlation: parseFloat(pacfRegular['pacf'][i])
});
}
const acfResiduals = response['acf.param']['acf.residuals.parameters'];
const acfResValues = [];
for (let i = 0; i < acfResiduals['acf.residuals.lag'].length; i++) {
acfResValues.push({
lag: parseFloat(acfResiduals['acf.residuals.lag'][i]),
correlation: parseFloat(acfResiduals['acf.residuals'][i])
});
}
const pacfResiduals = response['acf.param']['pacf.residuals.parameters'];
const pacfResValues = [];
for (let i = 0; i < pacfResiduals['pacf.residuals.lag'].length; i++) {
pacfResValues.push({
lag: parseFloat(pacfResiduals['pacf.residuals.lag'][i]),
correlation: parseFloat(pacfResiduals['pacf.residuals'][i])
});
}
const stl_plot = response.decomposition['stl.plot'];
const trends: any = [];
for (let i = 0; i < stl_plot.time.length; i++) {
const val: any = {
year: parseInt(stl_plot.time[i], 10),
amount: parseFloat(stl_plot.trend[i])
};
if (stl_plot['conf.interval.low']) {
if (!isNaN(stl_plot['conf.interval.low'][i])) {
val.low80 = parseFloat(stl_plot['conf.interval.low'][i]);
}
}
if (stl_plot['conf.interval.up']) {
if (!isNaN(stl_plot['conf.interval.up'][i])) {
val.up80 = parseFloat(stl_plot['conf.interval.up'][i]);
//.........这里部分代码省略.........
示例4: getParams
protected getParams():URLSearchParams{
let params = new URLSearchParams();
this._select && params.set("$select", this._select);
this._expand && params.set("$expand", this._expand);
return params;
}
示例5: getPerson
getPerson(nhsNumber : string) : Observable<UIPatient> {
var params = new URLSearchParams();
params.append('nhsNumber', nhsNumber);
return this.httpGet('api/recordViewer/getPerson', {search: params});
}
示例6: getServiceName
getServiceName(uuid : string) : Observable<string> {
let params = new URLSearchParams();
params.set('serviceId', uuid);
return this.httpGet('api/recordViewer/getServiceName', {search: params});
}
示例7: params
public params(object: Object) : URLSearchParams {
let params: URLSearchParams = null;
if (object) {
let paramsLength = 0;
params = new URLSearchParams();
for (var key in object) {
if (!object.hasOwnProperty(key)) {
continue;
}
var obj = object[key];
if (obj === undefined || obj === null) {
continue;
}
if (key === 'ordenamiento' && typeof obj === "object") {
let fields = "";
let firstField = true;
for (var subKey in obj) {
if (!obj.hasOwnProperty(subKey)) {
continue;
}
let value = obj[subKey];
if (value === undefined) {
continue;
}
let prefix = firstField ? "" : ",";
let order = ""; //asc
if (obj[subKey] === false) {
order = "-"; //desc
}
fields += `${prefix}${order}${subKey}`;
firstField = false;
}
if (fields.length > 0) {
params.append(key, fields);
}
} else {
params.append(key, obj);
}
paramsLength++;
}
if (!paramsLength) {
params = null;
}
}
return params;
}
示例8: getProcesses
getProcesses(sort: string): Observable<any> {
let params: URLSearchParams = new URLSearchParams();
params.set('sort', sort);
return this.getData('/system/os/processes', params);
}
示例9: getActiveTournaments
public getActiveTournaments(): Observable<Tournament[]> {
let params = new URLSearchParams();
params.set('state', 'active');
return this.getTournaments(params);
}
示例10:
Object.keys(params || {}).forEach(key => { searchParams.append(key, params[key]) })