问题
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