I'm using Angular with ui-router. I am attempting to refactor some code that looks like this:
window.location.hash = "order/" + vm.selectedRow.ID;
to this:
$state.go("^.order", {orderId: vm.selectedRow.ID} )
Changing to use $state.go handles navigating to the route just fine, however, it gets there before the URL has been updated. In the constructor for the associated controller I am grabbing an orderId from the end of the current url and using it in a query. I'm using this code:
var strings = window.location.href.split('/');
return strings[strings.length - 1];
to get the key.
Should I: 1. Continue to set window.location.hash instead of using $state.go, 2. Refactor to use $location because it lets me get to the pending URL, 3. Pass the ID value to the controller that's used by the new route?