Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change hash without reloading controller in AngularJS

I'm working on a currency converter, and I have url like #/currency/50/USD/to/EUR, where 50, USD and EUR are parameters. Now I have a switch function which swaps the currencies and keep the value to convert, I'd like to change the URL as well to something like #/currency/50/EUR/to/USD without reloading the controller, just change the hash. I have an idea on how to do with pure js, but is there any solution in angular way?

like image 430
Jonathan de M. Avatar asked Nov 30 '22 03:11

Jonathan de M.


1 Answers

Check this answer out. It sounds just like what you need.

Basically, you seem to have two choices:

  1. Listen for $locationChangeSuccess event.
  2. In your $routeProvider definition, while defining the routes and the corresponding templated to load, specify the option reloadOnSearch = false.
like image 84
callmekatootie Avatar answered Dec 04 '22 11:12

callmekatootie