Angular2 adds true to empty query parameters

寵の児 提交于 2019-12-24 06:38:25

问题


When navigating to a url like this:

/some/url;page=1;q=

The url gets automatically changed to:

/some/url;page=1;q=true

Is it possible to disable this so that i could have an empty parameter?


回答1:


I've been having the same issue in my application and so far, the only thing that has worked for me is removing the empty url parameter entirely. So if this is the url

/some/url;page=1;q=

when you check the url params, if q === '', you can remove q from the object with delete() to get this

/some/url;page=1

I understand this is not the best solution, I would love to find a fix that does not involving checking for empty url parameters all over my code.

I also understand the benefit of keeping q= in the url, even if the parameter is empty, I have just not found a way to do that yet.



来源:https://stackoverflow.com/questions/39227160/angular2-adds-true-to-empty-query-parameters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!