简体   繁体   English

如何从带有Angular 6参数的服务器获取URL

[英]How to get an URL from a server with parameter with Angular 6

i'am trying to get an URL from java backend in my angular's application,i have to pass the number of the folder inside the URL in order to get a list from that folder, what's the appropriate fomat that i should write ? 我正在尝试从我的angular应用程序中的java后端获取URL,我必须传递URL内文件夹的编号才能从该文件夹获取列表,我应该写什么合适的格式? how to personalize it in order to accept any number of folder , for this example 255 如何个性化它以接受任意数量的文件夹,例如255

this's the URL 这是URL

enter code here

public DD_LIST = '/app/api/demandes/225/listesdemanedes';

and the service is : 服务是:

enter code here   getlistes(): Observable<any> {
const api = {method : 'GET', url : this.DD_LIST };
return  this.http.request(api, null).pipe(
  map(response => ({
      content: response
  }))
);

} }

Use javascript string interpolation to form the URL as like below, 使用JavaScript字符串内插法形成如下所示的URL,

let folderNumber = 225;
public DD_LIST = `/app/api/demandes/${folderNumber}/listesdemanedes`;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM