如何在Angular 6中获取特定的网址模式

时间:2018-10-08 15:04:29

标签: javascript angular url router

我想要一个特定的URL模式。示例如下:

localhost / reports / orderproducts?filter = 1&from = 01.10.2018&to = 31.10.2018&admins = 45%2C32%2C43&product = 0&categories = 5%2C2

现在我得到:

localhost / reports / orderproducts?filter = 1&from = 01.10.2018&to = 31.10.2018&admins = 45&admins = 32&admins = 43&product = 0&categories = 5&categories = 2

    submitFiltration(form: NgForm) : void {
      let params : Object = MiscUtils.filterObject(this.formData);
      params['filter'] = 1;
      this.router.navigate([], {queryParams: params});
      this.submitted.emit(this.formData);
    }

param object

感谢您的帮助。最好的帮助是帮助我理解该方法。预先感谢

1 个答案:

答案 0 :(得分:0)

您正尝试在您的示例中显示为URL编码的字符串,例如admins=45%2C32%2,实际上是admins=45,32,43,如果要这样显示,则必须将具有join(',')的数组添加到你会被昏迷分开。

示例:

let stringParam = adminsArray.join(',');