argos/dmp-frontend/src/app/utilities/UrlUtilities.ts

18 lines
414 B
TypeScript

import { Injectable } from '@angular/core';
@Injectable()
export class UrlUtilities {
public applyUrlTemplate(url: string, params: any): string {
let paramsToString = '';
if (params) { paramsToString = '?'; }
const keys = Object.keys(params);
keys.forEach(x => {
if (keys.indexOf(x) > 0) { paramsToString += '&'; }
paramsToString += x + '=' + params[x];
});
return url + paramsToString;
}
}