$location.search({ke:val}) redirected to previous url


#1

I’m trying to make my search bar hide, when the user press the back button.
The search bar can be open in all pages so I can’t really add just one “search view”

I figured i need to add parameter to the url like this:
?search=1
when the user open the search bar , So I could track the action in the history.

Unfortunately, for some reasone When I use
$location.search({search: 1})
the user is being automatically redirected to the previus url instead

Could you please be awesome and help me solve this?

Thank you in advanced!